Program: 167737
Project: 167737
Buggy source:
@Override public void handleRequest(final HttpServerExchange exchange){
  final ModelNode dmr;
  final OperationResponse response;
  final HeaderMap requestHeaders=exchange.getRequestHeaders();
  final boolean cachable;
  final boolean get=exchange.getRequestMethod().equals(Methods.GET);
  final boolean encode=Common.APPLICATION_DMR_ENCODED.equals(requestHeaders.getFirst(Headers.ACCEPT)) || Common.APPLICATION_DMR_ENCODED.equals(requestHeaders.getFirst(Headers.CONTENT_TYPE));
  final OperationParameter.Builder operationParameterBuilder=new OperationParameter.Builder(get).encode(encode);
  final int streamIndex=getStreamIndex(exchange,requestHeaders);
  try {
    if (get) {
      GetOperation operation=getOperation(exchange);
      operationParameterBuilder.maxAge(operation.getMaxAge());
      dmr=convertGetRequest(exchange,operation);
      cachable=operation.getMaxAge() > 0;
    }
 else {
      dmr=convertPostRequest(exchange,encode);
      cachable=false;
    }
    operationParameterBuilder.pretty(dmr.hasDefined("String_Node_Str") && dmr.get("String_Node_Str").asBoolean());
  }
 catch (  Exception e) {
    ROOT_LOGGER.debugf("String_Node_Str",e.getMessage());
    Common.sendError(exchange,false,e.toString());
    return;
  }
  final ResponseCallback callback=new ResponseCallback(){
    @Override void doSendResponse(    final OperationResponse response){
      boolean closeResponse=true;
      try {
        ModelNode responseNode=response.getResponseNode();
        if (responseNode.hasDefined(OUTCOME) && FAILED.equals(responseNode.get(OUTCOME).asString())) {
          Common.sendError(exchange,encode,responseNode);
          return;
        }
        if (streamIndex < 0) {
          writeResponse(exchange,200,responseNode,operationParameterBuilder.build());
        }
 else {
          List<OperationResponse.StreamEntry> streamEntries=response.getInputStreams();
          if (streamIndex >= streamEntries.size()) {
            Common.sendError(exchange,encode,new ModelNode(HttpServerLogger.ROOT_LOGGER.invalidUseStreamAsResponseIndex(streamIndex,streamEntries.size())),400);
          }
 else {
            closeResponse=false;
            writeResponse(exchange,200,response,streamIndex,operationParameterBuilder.build());
          }
        }
      }
  finally {
        if (closeResponse) {
          StreamUtils.safeClose(response);
        }
      }
    }
  }
;
  final boolean sendPreparedResponse=sendPreparedResponse(dmr);
  final ModelController.OperationTransactionControl control=sendPreparedResponse ? new ModelController.OperationTransactionControl(){
    @Override public void operationPrepared(    final ModelController.OperationTransaction transaction,    final ModelNode result){
      transaction.commit();
      result.get(OUTCOME).set(SUCCESS);
      result.get(RESULT);
      callback.sendResponse(OperationResponse.Factory.createSimple(result));
    }
  }
 : ModelController.OperationTransactionControl.COMMIT;
  try {
    dmr.get(OPERATION_HEADERS,ACCESS_MECHANISM).set(AccessMechanism.HTTP.toString());
    response=modelController.execute(new OperationBuilder(dmr).build(),OperationMessageHandler.logging,control);
    if (cachable && streamIndex > -1) {
      MessageDigest md=MessageDigest.getInstance("String_Node_Str");
      md.update(response.toString().getBytes());
      ETag etag=new ETag(false,HexConverter.convertToHexString(md.digest()));
      operationParameterBuilder.etag(etag);
      if (!ETagUtils.handleIfNoneMatch(exchange,etag,false)) {
        exchange.setResponseCode(304);
        DomainUtil.writeCacheHeaders(exchange,304,operationParameterBuilder.build());
        exchange.endExchange();
        return;
      }
    }
  }
 catch (  Throwable t) {
    ROOT_LOGGER.modelRequestError(t);
    Common.sendError(exchange,encode,t.getLocalizedMessage());
    return;
  }
  callback.sendResponse(response);
}

Fixed version (ground truth):
@Override public void handleRequest(final HttpServerExchange exchange){
  final ModelNode dmr;
  final OperationResponse response;
  final HeaderMap requestHeaders=exchange.getRequestHeaders();
  final boolean cachable;
  final boolean get=exchange.getRequestMethod().equals(Methods.GET);
  final boolean encode=Common.APPLICATION_DMR_ENCODED.equals(requestHeaders.getFirst(Headers.ACCEPT)) || Common.APPLICATION_DMR_ENCODED.equals(requestHeaders.getFirst(Headers.CONTENT_TYPE));
  final OperationParameter.Builder operationParameterBuilder=new OperationParameter.Builder(get).encode(encode);
  final int streamIndex=getStreamIndex(exchange,requestHeaders);
  try {
    if (get) {
      GetOperation operation=getOperation(exchange);
      operationParameterBuilder.maxAge(operation.getMaxAge());
      dmr=convertGetRequest(exchange,operation);
      cachable=operation.getMaxAge() > 0;
    }
 else {
      dmr=convertPostRequest(exchange,encode);
      cachable=false;
    }
    boolean pretty=false;
    if (dmr.hasDefined(JSON_PRETTY)) {
      String jsonPretty=dmr.get(JSON_PRETTY).asString();
      pretty=jsonPretty.equals("String_Node_Str") || jsonPretty.equals("String_Node_Str");
    }
    operationParameterBuilder.pretty(pretty);
  }
 catch (  Exception e) {
    ROOT_LOGGER.debugf("String_Node_Str",e.getMessage());
    Common.sendError(exchange,false,e.toString());
    return;
  }
  final ResponseCallback callback=new ResponseCallback(){
    @Override void doSendResponse(    final OperationResponse response){
      boolean closeResponse=true;
      try {
        ModelNode responseNode=response.getResponseNode();
        if (responseNode.hasDefined(OUTCOME) && FAILED.equals(responseNode.get(OUTCOME).asString())) {
          Common.sendError(exchange,encode,responseNode);
          return;
        }
        if (streamIndex < 0) {
          writeResponse(exchange,200,responseNode,operationParameterBuilder.build());
        }
 else {
          List<OperationResponse.StreamEntry> streamEntries=response.getInputStreams();
          if (streamIndex >= streamEntries.size()) {
            Common.sendError(exchange,encode,new ModelNode(HttpServerLogger.ROOT_LOGGER.invalidUseStreamAsResponseIndex(streamIndex,streamEntries.size())),400);
          }
 else {
            closeResponse=false;
            writeResponse(exchange,200,response,streamIndex,operationParameterBuilder.build());
          }
        }
      }
  finally {
        if (closeResponse) {
          StreamUtils.safeClose(response);
        }
      }
    }
  }
;
  final boolean sendPreparedResponse=sendPreparedResponse(dmr);
  final ModelController.OperationTransactionControl control=sendPreparedResponse ? new ModelController.OperationTransactionControl(){
    @Override public void operationPrepared(    final ModelController.OperationTransaction transaction,    final ModelNode result){
      transaction.commit();
      result.get(OUTCOME).set(SUCCESS);
      result.get(RESULT);
      callback.sendResponse(OperationResponse.Factory.createSimple(result));
    }
  }
 : ModelController.OperationTransactionControl.COMMIT;
  try {
    dmr.get(OPERATION_HEADERS,ACCESS_MECHANISM).set(AccessMechanism.HTTP.toString());
    response=modelController.execute(new OperationBuilder(dmr).build(),OperationMessageHandler.logging,control);
    if (cachable && streamIndex > -1) {
      MessageDigest md=MessageDigest.getInstance("String_Node_Str");
      md.update(response.toString().getBytes());
      ETag etag=new ETag(false,HexConverter.convertToHexString(md.digest()));
      operationParameterBuilder.etag(etag);
      if (!ETagUtils.handleIfNoneMatch(exchange,etag,false)) {
        exchange.setResponseCode(304);
        DomainUtil.writeCacheHeaders(exchange,304,operationParameterBuilder.build());
        exchange.endExchange();
        return;
      }
    }
  }
 catch (  Throwable t) {
    ROOT_LOGGER.modelRequestError(t);
    Common.sendError(exchange,encode,t.getLocalizedMessage());
    return;
  }
  callback.sendResponse(response);
}