Program: 8048
Project: 8048
Buggy source:
@Override public void messageReceived(ChannelHandlerContext context,MessageEvent message) throws Exception {
  HttpRequest request=(HttpRequest)message.getMessage();
  HttpMethod method=request.getMethod();
  String uri=request.getUri();
  LOG.trace("String_Node_Str" + method + "String_Node_Str"+ uri);
  MetricsHelper helper=new MetricsHelper(this.getClass(),this.metrics,this.accessor.getMetricsQualifier());
  try {
    if (method != HttpMethod.GET) {
      LOG.trace("String_Node_Str" + method + "String_Node_Str");
      respondNotAllowed(message.getChannel(),allowedMethods);
      helper.finish(BadRequest);
      return;
    }
    QueryStringDecoder decoder=new QueryStringDecoder(uri);
    Map<String,List<String>> parameters=decoder.getParameters();
    String path=decoder.getPath();
    if (!accessor.getAuthenticator().authenticateRequest(request)) {
      respondError(message.getChannel(),HttpResponseStatus.FORBIDDEN);
      helper.finish(BadRequest);
      return;
    }
    String accountId=accessor.getAuthenticator().getAccountId(request);
    if ("String_Node_Str".equals(path)) {
      helper.setMethod("String_Node_Str");
      respondToPing(message.getChannel(),request);
      helper.finish(Success);
      return;
    }
    if ("String_Node_Str".equals(path)) {
      helper.setMethod("String_Node_Str");
      StringBuilder resp=new StringBuilder();
      boolean first=true;
      Map<String,Integer> statusmetrics=new HashMap<String,Integer>();
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      AppFabricService.Client flowClient=this.getFlowClient();
      List<ActiveFlow> activeFlows=flowClient.getFlows(accountId);
      for (      ActiveFlow activeFlow : activeFlows) {
        if (!"String_Node_Str".equals(activeFlow.getCurrentState())) {
          int count=statusmetrics.containsKey(activeFlow.getCurrentState()) ? statusmetrics.get(activeFlow.getCurrentState()) : 0;
          statusmetrics.put(activeFlow.getCurrentState(),count + 1);
        }
        MetricsFrontendService.Client metricsClient=this.getMetricsClient();
        CounterRequest counterRequest=new CounterRequest(new FlowArgument(accountId,activeFlow.getApplicationId(),activeFlow.getFlowId()));
        List<String> counterNames=parameters.get("String_Node_Str");
        if (counterNames != null) {
          counterRequest.setName(counterNames);
        }
        List<Counter> counters=metricsClient.getCounters(counterRequest);
        for (        Counter counter : counters) {
          if (first)           first=false;
 else           resp.append(',');
          if (counter.isSetQualifier()) {
            resp.append("String_Node_Str").append(activeFlow.getApplicationId()).append('.');
            resp.append(activeFlow.getFlowId()).append('.');
            resp.append(counter.getQualifier()).append("String_Node_Str");
          }
          resp.append(counter.getName()).append('=').append(counter.getValue());
        }
      }
      for (      Map.Entry<String,Integer> entry : statusmetrics.entrySet()) {
        String key=entry.getKey();
        int value=entry.getValue();
        if (first)         first=false;
 else         resp.append(',');
        resp.append("String_Node_Str").append(key.toLowerCase()).append('=').append(value);
      }
      respondSuccess(message.getChannel(),request,resp.toString().getBytes());
      helper.finish(Success);
      return;
    }
    String appid=null, flowid=null, query=null;
    if (path.startsWith(this.pathPrefix)) {
      int pos1=path.indexOf("String_Node_Str",this.pathPrefix.length());
      if (pos1 > this.pathPrefix.length()) {
        int pos2=path.indexOf("String_Node_Str",pos1 + 1);
        if (pos2 > pos1 + 1) {
          int pos3=path.indexOf("String_Node_Str",pos2 + 1);
          if (pos3 < 0 && path.length() > pos2) {
            appid=path.substring(this.pathPrefix.length(),pos1);
            flowid=path.substring(pos1 + 1,pos2);
            query=path.substring(pos2 + 1);
          }
        }
      }
    }
    if (appid == null) {
      helper.finish(BadRequest);
      LOG.trace("String_Node_Str" + uri);
      respondError(message.getChannel(),HttpResponseStatus.NOT_FOUND);
      return;
    }
    if (!("String_Node_Str".equals(query) || "String_Node_Str".equals(query))) {
      helper.finish(BadRequest);
      LOG.trace("String_Node_Str" + query);
      respondError(message.getChannel(),HttpResponseStatus.NOT_FOUND);
      return;
    }
    helper.setMethod("String_Node_Str");
    if ("String_Node_Str".equals(query)) {
      AppFabricService.Client flowClient=this.getFlowClient();
      FlowStatus status=flowClient.status(new AuthToken(),new FlowIdentifier(accountId,appid,flowid,-1));
      String value=status.getStatus();
      respondSuccess(message.getChannel(),request,value.getBytes());
      helper.finish(Success);
    }
 else     if ("String_Node_Str".equals(query)) {
      MetricsFrontendService.Client metricsClient=this.getMetricsClient();
      CounterRequest counterRequest=new CounterRequest(new FlowArgument(accountId,appid,flowid));
      List<String> counterNames=parameters.get("String_Node_Str");
      if (counterNames != null) {
        counterRequest.setName(counterNames);
      }
      List<Counter> counters=metricsClient.getCounters(counterRequest);
      StringBuilder str=new StringBuilder();
      boolean first=true;
      for (      Counter counter : counters) {
        if (first)         first=false;
 else         str.append(',');
        if (counter.isSetQualifier()) {
          str.append(counter.getQualifier()).append("String_Node_Str");
        }
        str.append(counter.getName()).append('=').append(counter.getValue());
      }
      respondSuccess(message.getChannel(),request,str.toString().getBytes());
      helper.finish(Success);
    }
 else {
      helper.finish(Error);
      respondError(message.getChannel(),HttpResponseStatus.INTERNAL_SERVER_ERROR);
    }
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str" + this.accessor.getName() + "String_Node_Str",e.getCause());
    helper.finish(Error);
    if (message.getChannel().isOpen()) {
      respondError(message.getChannel(),HttpResponseStatus.INTERNAL_SERVER_ERROR);
      message.getChannel().close();
    }
  }
}

Fixed version (ground truth):
@Override public void messageReceived(ChannelHandlerContext context,MessageEvent message) throws Exception {
  HttpRequest request=(HttpRequest)message.getMessage();
  HttpMethod method=request.getMethod();
  String uri=request.getUri();
  LOG.trace("String_Node_Str" + method + "String_Node_Str"+ uri);
  MetricsHelper helper=new MetricsHelper(this.getClass(),this.metrics,this.accessor.getMetricsQualifier());
  try {
    if (method != HttpMethod.GET) {
      LOG.trace("String_Node_Str" + method + "String_Node_Str");
      respondNotAllowed(message.getChannel(),allowedMethods);
      helper.finish(BadRequest);
      return;
    }
    QueryStringDecoder decoder=new QueryStringDecoder(uri);
    Map<String,List<String>> parameters=decoder.getParameters();
    String path=decoder.getPath();
    if (!accessor.getAuthenticator().authenticateRequest(request)) {
      respondError(message.getChannel(),HttpResponseStatus.FORBIDDEN);
      helper.finish(BadRequest);
      return;
    }
    String accountId=accessor.getAuthenticator().getAccountId(request);
    if ("String_Node_Str".equals(path)) {
      helper.setMethod("String_Node_Str");
      respondToPing(message.getChannel(),request);
      helper.finish(Success);
      return;
    }
    if ("String_Node_Str".equals(path)) {
      helper.setMethod("String_Node_Str");
      StringBuilder resp=new StringBuilder();
      boolean first=true;
      Map<String,Integer> statusmetrics=new HashMap<String,Integer>();
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      statusmetrics.put("String_Node_Str",0);
      AppFabricService.Client flowClient=this.getFlowClient();
      List<ActiveFlow> activeFlows=flowClient.getFlows(accountId);
      for (      ActiveFlow activeFlow : activeFlows) {
        if (!"String_Node_Str".equals(activeFlow.getCurrentState())) {
          int count=statusmetrics.containsKey(activeFlow.getCurrentState()) ? statusmetrics.get(activeFlow.getCurrentState()) : 0;
          statusmetrics.put(activeFlow.getCurrentState(),count + 1);
        }
        MetricsFrontendService.Client metricsClient=this.getMetricsClient();
        CounterRequest counterRequest=new CounterRequest(new FlowArgument(accountId,activeFlow.getApplicationId(),activeFlow.getFlowId()));
        List<String> counterNames=parameters.get("String_Node_Str");
        if (counterNames != null) {
          counterRequest.setName(counterNames);
        }
        List<Counter> counters=metricsClient.getCounters(counterRequest);
        for (        Counter counter : counters) {
          if (first)           first=false;
 else           resp.append(',');
          if (counter.isSetQualifier()) {
            resp.append("String_Node_Str").append(activeFlow.getApplicationId()).append('.');
            resp.append(activeFlow.getFlowId()).append('.');
            resp.append(counter.getQualifier()).append("String_Node_Str");
          }
          resp.append(counter.getName()).append('=').append(counter.getValue());
        }
      }
      for (      Map.Entry<String,Integer> entry : statusmetrics.entrySet()) {
        String key=entry.getKey();
        int value=entry.getValue();
        if (first)         first=false;
 else         resp.append(',');
        resp.append("String_Node_Str").append(key.toLowerCase()).append('=').append(value);
      }
      respondSuccess(message.getChannel(),request,resp.toString().getBytes());
      helper.finish(Success);
      return;
    }
    String appid=null, flowid=null, query=null;
    if (path.startsWith(this.pathPrefix)) {
      int pos1=path.indexOf("String_Node_Str",this.pathPrefix.length());
      if (pos1 > this.pathPrefix.length()) {
        int pos2=path.indexOf("String_Node_Str",pos1 + 1);
        if (pos2 > pos1 + 1) {
          int pos3=path.indexOf("String_Node_Str",pos2 + 1);
          if (pos3 < 0 && path.length() > pos2) {
            appid=path.substring(this.pathPrefix.length(),pos1);
            flowid=path.substring(pos1 + 1,pos2);
            query=path.substring(pos2 + 1);
          }
        }
      }
    }
    if (appid == null) {
      helper.finish(BadRequest);
      LOG.trace("String_Node_Str" + uri);
      respondError(message.getChannel(),HttpResponseStatus.NOT_FOUND);
      return;
    }
    if (!("String_Node_Str".equals(query) || "String_Node_Str".equals(query))) {
      helper.finish(BadRequest);
      LOG.trace("String_Node_Str" + query);
      respondError(message.getChannel(),HttpResponseStatus.NOT_FOUND);
      return;
    }
    helper.setMethod("String_Node_Str");
    if ("String_Node_Str".equals(query)) {
      AppFabricService.Client flowClient=this.getFlowClient();
      FlowStatus status=flowClient.status(new AuthToken(),new FlowIdentifier(accountId,appid,flowid,-1));
      String value=status.getStatus();
      respondSuccess(message.getChannel(),request,value.getBytes());
      helper.finish(Success);
    }
 else     if ("String_Node_Str".equals(query)) {
      MetricsFrontendService.Client metricsClient=this.getMetricsClient();
      CounterRequest counterRequest=new CounterRequest(new FlowArgument(accountId,appid,flowid));
      List<String> counterNames=parameters.get("String_Node_Str");
      if (counterNames != null) {
        counterRequest.setName(counterNames);
      }
      List<Counter> counters=metricsClient.getCounters(counterRequest);
      StringBuilder str=new StringBuilder();
      boolean first=true;
      for (      Counter counter : counters) {
        if (first)         first=false;
 else         str.append(',');
        if (counter.isSetQualifier()) {
          str.append(counter.getQualifier()).append("String_Node_Str");
        }
        str.append(counter.getName()).append('=').append(counter.getValue());
      }
      respondSuccess(message.getChannel(),request,str.toString().getBytes());
      helper.finish(Success);
    }
 else {
      helper.finish(Error);
      respondError(message.getChannel(),HttpResponseStatus.INTERNAL_SERVER_ERROR);
    }
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str" + this.accessor.getName() + "String_Node_Str",e);
    helper.finish(Error);
    if (message.getChannel().isOpen()) {
      respondError(message.getChannel(),HttpResponseStatus.INTERNAL_SERVER_ERROR);
      message.getChannel().close();
    }
  }
}