Program: 93447
Project: 93447
Buggy source:
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(final HttpServerExchange exchange,final RequestContext context) throws Exception {
  if (context.isInError()) {
    next(exchange,context);
    return;
  }
  if (context.getMethod() == RequestContext.METHOD.GET || context.getMethod() == RequestContext.METHOD.OPTIONS || context.getMethod() == RequestContext.METHOD.DELETE) {
    next(exchange,context);
    return;
  }
  BsonValue content;
  final HeaderValues contentType=exchange.getRequestHeaders().get(Headers.CONTENT_TYPE);
  if (isFormOrMultipart(contentType)) {
    if (!((isPostRequest(context) && isFilesBucketRequest(context)) || (isPutRequest(context) && isFileRequest(context)))) {
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE,ERROR_INVALID_CONTENTTYPE_FILE);
      next(exchange,context);
      return;
    }
    FormDataParser parser=this.formParserFactory.createParser(exchange);
    if (parser == null) {
      String errMsg="String_Node_Str" + "String_Node_Str";
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
      next(exchange,context);
      return;
    }
    FormData formData;
    try {
      formData=parser.parseBlocking();
    }
 catch (    IOException ioe) {
      String errMsg="String_Node_Str" + "String_Node_Str";
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg,ioe);
      next(exchange,context);
      return;
    }
    try {
      content=extractMetadata(formData);
    }
 catch (    JSONParseException|IllegalArgumentException ex) {
      String errMsg="String_Node_Str" + "String_Node_Str";
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg,ex);
      next(exchange,context);
      return;
    }
    final String fileField=extractFileField(formData);
    if (fileField == null) {
      String errMsg="String_Node_Str";
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
      next(exchange,context);
      return;
    }
    final Path path=formData.getFirst(fileField).getPath();
    context.setFilePath(path);
    injectContentTypeFromFile(content.asDocument(),path.toFile());
  }
 else   if (isHalOrJson(contentType)) {
    final String contentString=ChannelReader.read(exchange.getRequestChannel());
    context.setRawContent(contentString);
    if (contentString != null && !contentString.isEmpty()) {
      try {
        content=JsonUtils.parse(contentString);
        if (content != null && !content.isDocument() && !content.isArray()) {
          throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ content.getBsonType().name());
        }
      }
 catch (      JsonParseException|IllegalArgumentException ex) {
        ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,"String_Node_Str",ex);
        next(exchange,context);
        return;
      }
    }
 else {
      content=null;
    }
  }
 else   if (contentType == null) {
    content=null;
  }
 else {
    ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE,ERROR_INVALID_CONTENTTYPE);
    next(exchange,context);
    return;
  }
  if (content == null) {
    content=new BsonDocument();
  }
 else   if (content.isArray()) {
    if (context.getType() != RequestContext.TYPE.COLLECTION || (context.getMethod() != RequestContext.METHOD.POST)) {
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      next(exchange,context);
      return;
    }
    if (!content.asArray().stream().anyMatch(_doc -> {
      if (_doc.isDocument()) {
        BsonValue _id=_doc.asDocument().get(_ID);
        if (_id != null && _id.isArray()) {
          String errMsg="String_Node_Str" + "String_Node_Str" + (_id == null ? "String_Node_Str" : _id.getBsonType().name());
          ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
          return false;
        }
        filterJsonContent(_doc.asDocument(),context);
        return true;
      }
 else {
        String errMsg="String_Node_Str" + "String_Node_Str";
        ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
        return false;
      }
    }
)) {
      next(exchange,context);
      return;
    }
  }
 else   if (content.isDocument()) {
    BsonDocument _content=content.asDocument();
    BsonValue _id=_content.get(_ID);
    if (_id != null && _id.isArray()) {
      String errMsg="String_Node_Str" + "String_Node_Str" + (_id == null ? "String_Node_Str" : _id.getBsonType().name());
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
      next(exchange,context);
      return;
    }
    filterJsonContent(_content,context);
  }
  context.setContent(content);
  next(exchange,context);
}

Fixed version (ground truth):
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(final HttpServerExchange exchange,final RequestContext context) throws Exception {
  if (context.isInError()) {
    next(exchange,context);
    return;
  }
  if (context.getMethod() == RequestContext.METHOD.GET || context.getMethod() == RequestContext.METHOD.OPTIONS || context.getMethod() == RequestContext.METHOD.DELETE) {
    next(exchange,context);
    return;
  }
  BsonValue content;
  final HeaderValues contentType=exchange.getRequestHeaders().get(Headers.CONTENT_TYPE);
  if (isFormOrMultipart(contentType)) {
    if (!((isPostRequest(context) && isFilesBucketRequest(context)) || (isPutRequest(context) && isFileRequest(context)))) {
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE,ERROR_INVALID_CONTENTTYPE_FILE);
      next(exchange,context);
      return;
    }
    FormDataParser parser=this.formParserFactory.createParser(exchange);
    if (parser == null) {
      String errMsg="String_Node_Str" + "String_Node_Str";
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
      next(exchange,context);
      return;
    }
    FormData formData;
    try {
      formData=parser.parseBlocking();
    }
 catch (    IOException ioe) {
      String errMsg="String_Node_Str" + "String_Node_Str";
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg,ioe);
      next(exchange,context);
      return;
    }
    try {
      content=extractMetadata(formData);
    }
 catch (    JSONParseException|IllegalArgumentException ex) {
      String errMsg="String_Node_Str" + "String_Node_Str";
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg,ex);
      next(exchange,context);
      return;
    }
    final String fileField=extractFileField(formData);
    if (fileField == null) {
      String errMsg="String_Node_Str";
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
      next(exchange,context);
      return;
    }
    final Path path=formData.getFirst(fileField).getPath();
    context.setFilePath(path);
    injectContentTypeFromFile(content.asDocument(),path.toFile());
  }
 else {
    final String contentString=ChannelReader.read(exchange.getRequestChannel());
    context.setRawContent(contentString);
    if (isHalOrJson(contentType)) {
      if (contentString != null && !contentString.isEmpty()) {
        try {
          content=JsonUtils.parse(contentString);
          if (content != null && !content.isDocument() && !content.isArray()) {
            throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ content.getBsonType().name());
          }
        }
 catch (        JsonParseException|IllegalArgumentException ex) {
          ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,"String_Node_Str",ex);
          next(exchange,context);
          return;
        }
      }
 else {
        content=null;
      }
    }
 else     if (contentType == null) {
      content=null;
    }
 else {
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE,ERROR_INVALID_CONTENTTYPE);
      next(exchange,context);
      return;
    }
  }
  if (content == null) {
    content=new BsonDocument();
  }
 else   if (content.isArray()) {
    if (context.getType() != RequestContext.TYPE.COLLECTION || (context.getMethod() != RequestContext.METHOD.POST)) {
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      next(exchange,context);
      return;
    }
    if (!content.asArray().stream().anyMatch(_doc -> {
      if (_doc.isDocument()) {
        BsonValue _id=_doc.asDocument().get(_ID);
        if (_id != null && _id.isArray()) {
          String errMsg="String_Node_Str" + "String_Node_Str" + (_id == null ? "String_Node_Str" : _id.getBsonType().name());
          ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
          return false;
        }
        filterJsonContent(_doc.asDocument(),context);
        return true;
      }
 else {
        String errMsg="String_Node_Str" + "String_Node_Str";
        ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
        return false;
      }
    }
)) {
      next(exchange,context);
      return;
    }
  }
 else   if (content.isDocument()) {
    BsonDocument _content=content.asDocument();
    BsonValue _id=_content.get(_ID);
    if (_id != null && _id.isArray()) {
      String errMsg="String_Node_Str" + "String_Node_Str" + (_id == null ? "String_Node_Str" : _id.getBsonType().name());
      ResponseHelper.endExchangeWithMessage(exchange,context,HttpStatus.SC_NOT_ACCEPTABLE,errMsg);
      next(exchange,context);
      return;
    }
    filterJsonContent(_content,context);
  }
  context.setContent(content);
  next(exchange,context);
}