Program: 93442
Project: 93442
Buggy source:
/** 
 * Upsert the collection properties.
 * @param dbName the database name of the collection
 * @param collName the collection name
 * @param properties the new collection properties
 * @param requestEtag the entity tag. must match to allow actual write ifcheckEtag is true (otherwise http error code is returned)
 * @param updating true if updating existing document
 * @param patching true if use patch semantic (update only specified fields)
 * @param checkEtag true if etag must be checked
 * @return the HttpStatus code to set in the http response
 */
@SuppressWarnings("String_Node_Str") OperationResult upsertCollection(final String dbName,final String collName,final BsonDocument properties,final String requestEtag,final boolean updating,final boolean patching,final boolean checkEtag){
  if (patching && !updating) {
    return new OperationResult(HttpStatus.SC_NOT_FOUND);
  }
  if (!updating) {
    client.getDatabase(dbName).createCollection(collName);
  }
  ObjectId newEtag=new ObjectId();
  final BsonDocument content=DAOUtils.validContent(properties);
  content.put("String_Node_Str",new BsonObjectId(newEtag));
  content.remove("String_Node_Str");
  MongoDatabase mdb=client.getDatabase(dbName);
  MongoCollection<BsonDocument> mcoll=mdb.getCollection("String_Node_Str",BsonDocument.class);
  if (checkEtag && updating) {
    BsonDocument oldProperties=mcoll.find(eq("String_Node_Str","String_Node_Str".concat(collName))).projection(FIELDS_TO_RETURN).first();
    if (oldProperties != null) {
      BsonValue oldEtag=oldProperties.get("String_Node_Str");
      if (oldEtag != null && requestEtag == null) {
        return new OperationResult(HttpStatus.SC_CONFLICT,oldEtag);
      }
      BsonValue _requestEtag;
      if (ObjectId.isValid(requestEtag)) {
        _requestEtag=new BsonObjectId(new ObjectId(requestEtag));
      }
 else {
        _requestEtag=new BsonString(requestEtag);
      }
      if (Objects.equals(_requestEtag,oldEtag)) {
        return doCollPropsUpdate(collName,patching,updating,mcoll,content,newEtag);
      }
 else {
        return new OperationResult(HttpStatus.SC_PRECONDITION_FAILED,oldEtag);
      }
    }
 else {
      return doCollPropsUpdate(collName,patching,updating,mcoll,content,newEtag);
    }
  }
 else {
    return doCollPropsUpdate(collName,patching,updating,mcoll,content,newEtag);
  }
}

Fixed version (ground truth):
/** 
 * Upsert the collection properties.
 * @param dbName the database name of the collection
 * @param collName the collection name
 * @param properties the new collection properties
 * @param requestEtag the entity tag. must match to allow actual write ifcheckEtag is true (otherwise http error code is returned)
 * @param updating true if updating existing document
 * @param patching true if use patch semantic (update only specified fields)
 * @param checkEtag true if etag must be checked
 * @return the HttpStatus code to set in the http response
 */
@SuppressWarnings("String_Node_Str") OperationResult upsertCollection(final String dbName,final String collName,final BsonDocument properties,final String requestEtag,boolean updating,final boolean patching,final boolean checkEtag){
  if (patching && !updating) {
    return new OperationResult(HttpStatus.SC_NOT_FOUND);
  }
  if (!updating) {
    try {
      client.getDatabase(dbName).createCollection(collName);
    }
 catch (    MongoCommandException ex) {
      if (ex.getErrorCode() != 48) {
        throw ex;
      }
 else {
        updating=true;
      }
    }
  }
  ObjectId newEtag=new ObjectId();
  final BsonDocument content=DAOUtils.validContent(properties);
  content.put("String_Node_Str",new BsonObjectId(newEtag));
  content.remove("String_Node_Str");
  MongoDatabase mdb=client.getDatabase(dbName);
  MongoCollection<BsonDocument> mcoll=mdb.getCollection("String_Node_Str",BsonDocument.class);
  if (checkEtag && updating) {
    BsonDocument oldProperties=mcoll.find(eq("String_Node_Str","String_Node_Str".concat(collName))).projection(FIELDS_TO_RETURN).first();
    if (oldProperties != null) {
      BsonValue oldEtag=oldProperties.get("String_Node_Str");
      if (oldEtag != null && requestEtag == null) {
        return new OperationResult(HttpStatus.SC_CONFLICT,oldEtag);
      }
      BsonValue _requestEtag;
      if (ObjectId.isValid(requestEtag)) {
        _requestEtag=new BsonObjectId(new ObjectId(requestEtag));
      }
 else {
        _requestEtag=new BsonString(requestEtag);
      }
      if (Objects.equals(_requestEtag,oldEtag)) {
        return doCollPropsUpdate(collName,patching,updating,mcoll,content,newEtag);
      }
 else {
        return new OperationResult(HttpStatus.SC_PRECONDITION_FAILED,oldEtag);
      }
    }
 else {
      return doCollPropsUpdate(collName,patching,updating,mcoll,content,newEtag);
    }
  }
 else {
    return doCollPropsUpdate(collName,patching,updating,mcoll,content,newEtag);
  }
}