Program: 93562
Project: 93562
Buggy source:
/** 
 * @param exchange
 * @param dbName
 * @param collName
 * @param docId
 * @param content
 * @param requestEtag
 * @return
 */
@Override public int upsertDocumentPost(HttpServerExchange exchange,String dbName,String collName,Object documentId,DBObject content,ObjectId requestEtag){
  DB db=client.getDB(dbName);
  DBCollection coll=db.getCollection(collName);
  ObjectId timestamp=new ObjectId();
  Instant now=Instant.ofEpochSecond(timestamp.getTimestamp());
  if (content == null) {
    content=new BasicDBObject();
  }
  content.put("String_Node_Str",timestamp);
  content.put("String_Node_Str",now.toString());
  Object _idInContent=content.get("String_Node_Str");
  content.removeField("String_Node_Str");
  if (_idInContent == null) {
    content.put("String_Node_Str",documentId);
    coll.insert(content);
    exchange.getResponseHeaders().add(HttpString.tryFromString("String_Node_Str"),getReferenceLink(exchange.getRequestURL(),documentId.toString()).toString());
    return HttpStatus.SC_CREATED;
  }
 else {
    exchange.getResponseHeaders().add(HttpString.tryFromString("String_Node_Str"),getReferenceLink(exchange.getRequestURL(),_idInContent.toString()).toString());
  }
  BasicDBObject idQuery=new BasicDBObject("String_Node_Str",documentId);
  DBObject oldDocument=coll.findAndModify(idQuery,null,null,false,content,false,true);
  if (oldDocument != null) {
    Object oldTimestamp=oldDocument.get("String_Node_Str");
    if (oldTimestamp == null) {
      oldTimestamp=now.toString();
      LOGGER.warn("String_Node_Str",dbName,collName,_idInContent.toString());
    }
    BasicDBObject createdContent=new BasicDBObject("String_Node_Str","String_Node_Str" + oldTimestamp);
    createdContent.markAsPartialObject();
    coll.update(idQuery,new BasicDBObject("String_Node_Str",createdContent),true,false);
    return optimisticCheckEtag(coll,oldDocument,requestEtag,HttpStatus.SC_OK);
  }
 else {
    return HttpStatus.SC_CREATED;
  }
}

Fixed version (ground truth):
/** 
 * @param dbName
 * @param collName
 * @param docId
 * @param content
 * @param requestEtag
 * @return
 */
@Override public int upsertDocumentPost(String dbName,String collName,Object documentId,DBObject content,ObjectId requestEtag){
  DB db=client.getDB(dbName);
  DBCollection coll=db.getCollection(collName);
  ObjectId timestamp=new ObjectId();
  Instant now=Instant.ofEpochSecond(timestamp.getTimestamp());
  if (content == null) {
    content=new BasicDBObject();
  }
  content.put("String_Node_Str",timestamp);
  content.put("String_Node_Str",now.toString());
  Object _idInContent=content.get("String_Node_Str");
  content.removeField("String_Node_Str");
  if (_idInContent == null) {
    content.put("String_Node_Str",documentId);
    coll.insert(content);
    return HttpStatus.SC_CREATED;
  }
  BasicDBObject idQuery=new BasicDBObject("String_Node_Str",documentId);
  DBObject oldDocument=coll.findAndModify(idQuery,null,null,false,content,false,true);
  if (oldDocument != null) {
    Object oldTimestamp=oldDocument.get("String_Node_Str");
    if (oldTimestamp == null) {
      oldTimestamp=now.toString();
      LOGGER.warn("String_Node_Str",dbName,collName,_idInContent.toString());
    }
    BasicDBObject createdContent=new BasicDBObject("String_Node_Str","String_Node_Str" + oldTimestamp);
    createdContent.markAsPartialObject();
    coll.update(idQuery,new BasicDBObject("String_Node_Str",createdContent),true,false);
    return optimisticCheckEtag(coll,oldDocument,requestEtag,HttpStatus.SC_OK);
  }
 else {
    return HttpStatus.SC_CREATED;
  }
}