nus-yam/ex-repair huggingface dataset:
Program: 54516
Project: 54516
Buggy source:
public void commit() throws RollbackException, UserException {
  try (MergerStage mergeStage=metainfoRepository.startMerge(metaSnapshot)){
    backendTransaction.commit();
    backendTransaction.close();
    mergeStage.commit();
  }
 }

Fixed version (ground truth):
public void commit() throws RollbackException, UserException {
  try (MergerStage mergeStage=metainfoRepository.startMerge(metaSnapshot)){
    backendTransaction.commit();
    mergeStage.commit();
  }
 }
Program: 54517
Project: 54517
Buggy source:
@Inject ConnectionCommandsExecutor(MapFactory mapFactory){
  ImmutableMap<Command<?,?>,CommandImplementation> supportedCommandsMap=mapFactory.get();
  supportedCommands=Collections.unmodifiableSet(supportedCommandsMap.entrySet().stream().filter((e) -> !(e.getValue() instanceof NotImplementedCommandImplementation)).map((e) -> e.getKey()).collect(Collectors.toSet()));
  delegate=MapBasedCommandsExecutor.<MongodConnection>builder().addImplementations(supportedCommandsMap.entrySet()).build();
}

Fixed version (ground truth):
@Inject ConnectionCommandsExecutor(MapFactory mapFactory){
  map=mapFactory.get();
  supportedCommands=Collections.unmodifiableSet(map.entrySet().stream().filter((e) -> !(e.getValue() instanceof NotImplementedCommandImplementation)).map((e) -> e.getKey()).collect(Collectors.toSet()));
}
Program: 54518
Project: 54518
Buggy source:
@Override public ImmutableMap<Command<?,?>,CommandImplementation> get(){
  MongoDb30CommandsImplementationBuilder implBuilder=new MongoDb30CommandsImplementationBuilder(adminBuilder,aggregationBuilder,authenticationCommandsImplementationsBuilder,diagnosticBuilder,generalBuilder,internalBuilder,replBuilder);
  ImmutableMap.Builder<Command<?,?>,CommandImplementation> builder=ImmutableMap.builder();
  for (  Entry<Command<?,?>,CommandImplementation> entry : implBuilder) {
    builder.put(entry.getKey(),entry.getValue());
  }
  return builder.build();
}

Fixed version (ground truth):
@Override public ImmutableMap<Command<?,?>,CommandImplementation<?,?,? super MongodConnection>> get(){
  MongoDb30CommandsImplementationBuilder<MongodConnection> implBuilder=new MongoDb30CommandsImplementationBuilder<>(adminBuilder,aggregationBuilder,authenticationCommandsImplementationsBuilder,diagnosticBuilder,generalBuilder,internalBuilder,replBuilder);
  ImmutableMap.Builder<Command<?,?>,CommandImplementation<?,?,? super MongodConnection>> builder=ImmutableMap.builder();
  for (  Entry<Command<?,?>,CommandImplementation<?,?,? super MongodConnection>> entry : implBuilder) {
    builder.put(entry.getKey(),entry.getValue());
  }
  return builder.build();
}
Program: 54519
Project: 54519
Buggy source:
@Locked(exclusive=true) private void loadState() throws OplogManagerPersistException {
  Status<? extends Object> result=retrier.retry(() -> {
    try (ReadOnlyMongodTransaction transaction=connection.openReadOnlyTransaction()){
      Status<FindResult> status=transaction.execute(new Request(OPLOG_DB,null,true,null),FindCommand.INSTANCE,new FindArgument.Builder().setComment(OPLOG_COL).setSlaveOk(true).build());
      if (!status.isOK()) {
        return status;
      }
      Iterator<BsonDocument> batch=status.getResult().getCursor().getFirstBatch();
      if (!batch.hasNext()) {
        lastAppliedHash=0;
        lastAppliedOpTime=OpTime.EPOCH;
      }
 else {
        BsonDocument doc=batch.next();
        BsonDocument subDoc=BsonReaderTool.getDocument(doc,KEY);
        lastAppliedHash=BsonReaderTool.getLong(subDoc,"String_Node_Str");
        BsonDocument opTimeDoc=BsonReaderTool.getDocument(subDoc,"String_Node_Str");
        lastAppliedOpTime=new OpTime(UnsignedInteger.valueOf(BsonReaderTool.getLong(opTimeDoc,"String_Node_Str")),UnsignedInteger.valueOf(BsonReaderTool.getLong(opTimeDoc,"String_Node_Str")));
      }
      return Status.ok();
    }
 catch (    MongoException ex) {
      return Status.from(ex);
    }
  }
);
  if (!result.isOK()) {
    throw new OplogManagerPersistException(result.getErrorCode(),result.getErrorMsg());
  }
}

Fixed version (ground truth):
@Locked(exclusive=true) private void loadState() throws OplogManagerPersistException {
  Status<? extends Object> result=retrier.retry(() -> {
    try (ReadOnlyMongodTransaction transaction=connection.openReadOnlyTransaction()){
      Status<FindResult> status=transaction.execute(new Request(OPLOG_DB,null,true,null),FindCommand.INSTANCE,new FindArgument.Builder().setCollection(OPLOG_COL).setSlaveOk(true).build());
      if (!status.isOK()) {
        return status;
      }
      Iterator<BsonDocument> batch=status.getResult().getCursor().getFirstBatch();
      if (!batch.hasNext()) {
        lastAppliedHash=0;
        lastAppliedOpTime=OpTime.EPOCH;
      }
 else {
        BsonDocument doc=batch.next();
        BsonDocument subDoc=BsonReaderTool.getDocument(doc,KEY);
        lastAppliedHash=BsonReaderTool.getLong(subDoc,"String_Node_Str");
        lastAppliedOpTime=new OpTime(UnsignedInteger.valueOf(BsonReaderTool.getLong(subDoc,"String_Node_Str")),UnsignedInteger.valueOf(BsonReaderTool.getLong(subDoc,"String_Node_Str")));
      }
      return Status.ok();
    }
 catch (    MongoException ex) {
      return Status.from(ex);
    }
  }
);
  if (!result.isOK()) {
    throw new OplogManagerPersistException(result.getErrorCode(),result.getErrorMsg());
  }
}
Program: 54520
Project: 54520
Buggy source:
@Locked(exclusive=true) private void storeState(long hash,OpTime opTime) throws OplogManagerPersistException {
  Preconditions.checkState(isRunning(),"String_Node_Str");
  Status<?> result=retrier.retry(() -> {
    try (WriteMongodTransaction transaction=connection.openWriteTransaction()){
      Status<Long> deleteResult=transaction.execute(new Request(OPLOG_DB,null,true,null),DeleteCommand.INSTANCE,new DeleteArgument.Builder(OPLOG_COL).addStatement(new DeleteStatement(DOC_QUERY,false)).build());
      if (!deleteResult.isOK()) {
        return deleteResult;
      }
      Status<InsertResult> insertResult=transaction.execute(new Request("String_Node_Str",null,true,null),InsertCommand.INSTANCE,new InsertArgument.Builder("String_Node_Str").addDocument(new BsonDocumentBuilder().appendUnsafe(KEY,new BsonDocumentBuilder().appendUnsafe("String_Node_Str",newLong(hash)).appendUnsafe("String_Node_Str",new BsonDocumentBuilder().appendUnsafe("String_Node_Str",newLong(opTime.getSecs().longValue())).appendUnsafe("String_Node_Str",newLong(opTime.getTerm().longValue())).build()).build()).build()).build());
      if (insertResult.isOK() && insertResult.getResult().getN() != 1) {
        return Status.from(ErrorCode.OPERATION_FAILED,"String_Node_Str");
      }
      return insertResult;
    }
   }
);
  if (!result.isOK()) {
    throw new OplogManagerPersistException(result.getErrorCode(),result.getErrorMsg());
  }
}

Fixed version (ground truth):
@Locked(exclusive=true) private void storeState(long hash,OpTime opTime) throws OplogManagerPersistException {
  Preconditions.checkState(isRunning(),"String_Node_Str");
  Status<?> result=retrier.retry(() -> {
    try (WriteMongodTransaction transaction=connection.openWriteTransaction()){
      Status<Long> deleteResult=transaction.execute(new Request(OPLOG_DB,null,true,null),DeleteCommand.INSTANCE,new DeleteArgument.Builder(OPLOG_COL).addStatement(new DeleteStatement(DOC_QUERY,false)).build());
      if (!deleteResult.isOK()) {
        return deleteResult;
      }
      Status<InsertResult> insertResult=transaction.execute(new Request(OPLOG_DB,null,true,null),InsertCommand.INSTANCE,new InsertArgument.Builder(OPLOG_COL).addDocument(new BsonDocumentBuilder().appendUnsafe(KEY,new BsonDocumentBuilder().appendUnsafe("String_Node_Str",newLong(hash)).appendUnsafe("String_Node_Str",newLong(opTime.getSecs().longValue())).appendUnsafe("String_Node_Str",newLong(opTime.getTerm().longValue())).build()).build()).build());
      if (insertResult.isOK() && insertResult.getResult().getN() != 1) {
        return Status.from(ErrorCode.OPERATION_FAILED,"String_Node_Str");
      }
      transaction.commit();
      return insertResult;
    }
   }
);
  if (!result.isOK()) {
    throw new OplogManagerPersistException(result.getErrorCode(),result.getErrorMsg());
  }
}
Program: 54521
Project: 54521
Buggy source:
private void analyzeScalar(MutableMetaDatabase db,MutableMetaDocPart metaDocPart,MetaScalarRecord<?> scalar,SchemaValidator schemaValidator){
  String docPartIdentifier=metaDocPart.getIdentifier();
  String schemaName=db.getIdentifier();
  String dbName=db.getName();
  TableRef fieldTableRef=scalar.getTableRefValue(tableRefFactory);
  if (!metaDocPart.getTableRef().equals(fieldTableRef)) {
    return;
  }
  metaDocPart.addMetaScalar(scalar.getIdentifier(),scalar.getType());
  if (!schemaValidator.existsColumn(docPartIdentifier,scalar.getIdentifier())) {
    throw new InvalidDatabaseSchemaException(schemaName,"String_Node_Str" + scalar.getCollection() + "String_Node_Str"+ scalar.getTableRefValue(tableRefFactory)+ "String_Node_Str"+ scalar.getType()+ "String_Node_Str"+ dbName+ "String_Node_Str"+ scalar.getIdentifier()+ "String_Node_Str"+ schemaName+ "String_Node_Str"+ docPartIdentifier);
  }
  if (!schemaValidator.existsColumnWithType(docPartIdentifier,scalar.getIdentifier(),sqlInterface.getDataTypeProvider().getDataType(scalar.getType()))) {
  }
}

Fixed version (ground truth):
private void analyzeScalar(MutableMetaDatabase db,MutableMetaDocPart metaDocPart,MetaScalarRecord<?> scalar,SchemaValidator schemaValidator){
  String docPartIdentifier=metaDocPart.getIdentifier();
  String schemaName=db.getIdentifier();
  String dbName=db.getName();
  TableRef fieldTableRef=scalar.getTableRefValue(tableRefFactory);
  if (!metaDocPart.getTableRef().equals(fieldTableRef)) {
    return;
  }
  metaDocPart.addMetaScalar(scalar.getIdentifier(),scalar.getType());
  if (!schemaValidator.existsColumn(docPartIdentifier,scalar.getIdentifier())) {
    throw new InvalidDatabaseSchemaException(schemaName,"String_Node_Str" + scalar.getCollection() + "String_Node_Str"+ scalar.getTableRefValue(tableRefFactory)+ "String_Node_Str"+ scalar.getType()+ "String_Node_Str"+ dbName+ "String_Node_Str"+ scalar.getIdentifier()+ "String_Node_Str"+ schemaName+ "String_Node_Str"+ docPartIdentifier);
  }
}
Program: 54522
Project: 54522
Buggy source:
private void analyzeField(MutableMetaDatabase db,MutableMetaDocPart metaDocPart,MetaFieldRecord<?> field,SchemaValidator schemaValidator){
  String docPartIdentifier=metaDocPart.getIdentifier();
  String schemaName=db.getIdentifier();
  String dbName=db.getName();
  TableRef fieldTableRef=field.getTableRefValue(tableRefFactory);
  if (!metaDocPart.getTableRef().equals(fieldTableRef)) {
    return;
  }
  metaDocPart.addMetaField(field.getName(),field.getIdentifier(),field.getType());
  if (!schemaValidator.existsColumn(docPartIdentifier,field.getIdentifier())) {
    throw new InvalidDatabaseSchemaException(schemaName,"String_Node_Str" + field.getCollection() + "String_Node_Str"+ field.getTableRefValue(tableRefFactory)+ "String_Node_Str"+ field.getName()+ "String_Node_Str"+ field.getType()+ "String_Node_Str"+ dbName+ "String_Node_Str"+ field.getIdentifier()+ "String_Node_Str"+ schemaName+ "String_Node_Str"+ docPartIdentifier);
  }
  if (!schemaValidator.existsColumnWithType(docPartIdentifier,field.getIdentifier(),sqlInterface.getDataTypeProvider().getDataType(field.getType()))) {
  }
}

Fixed version (ground truth):
private void analyzeField(MutableMetaDatabase db,MutableMetaDocPart metaDocPart,MetaFieldRecord<?> field,SchemaValidator schemaValidator){
  String docPartIdentifier=metaDocPart.getIdentifier();
  String schemaName=db.getIdentifier();
  String dbName=db.getName();
  TableRef fieldTableRef=field.getTableRefValue(tableRefFactory);
  if (!metaDocPart.getTableRef().equals(fieldTableRef)) {
    return;
  }
  metaDocPart.addMetaField(field.getName(),field.getIdentifier(),field.getType());
  if (!schemaValidator.existsColumn(docPartIdentifier,field.getIdentifier())) {
    throw new InvalidDatabaseSchemaException(schemaName,"String_Node_Str" + field.getCollection() + "String_Node_Str"+ field.getTableRefValue(tableRefFactory)+ "String_Node_Str"+ field.getName()+ "String_Node_Str"+ field.getType()+ "String_Node_Str"+ dbName+ "String_Node_Str"+ field.getIdentifier()+ "String_Node_Str"+ schemaName+ "String_Node_Str"+ docPartIdentifier);
  }
}
Program: 54523
Project: 54523
Buggy source:
@Override public synchronized Exception getCause(){
  return (Exception)super.getCause();
}

Fixed version (ground truth):
@Override public synchronized Exception getCause(){
  Throwable cause=super.getCause();
  if (cause instanceof Exception) {
    return (Exception)cause;
  }
  return null;
}
Program: 54524
Project: 54524
Buggy source:
@Override public synchronized UserException getCause(){
  return (UserException)super.getCause();
}

Fixed version (ground truth):
@Override public synchronized UserException getCause(){
  Exception cause=super.getCause();
  if (cause instanceof UserException) {
    return (UserException)cause;
  }
  return null;
}
Program: 54525
Project: 54525
Buggy source:
@Override public List<KVDocument> createListFrom(InputStream is){
  return converter.convert((List<Map<String,Object>>)gson.fromJson(new InputStreamReader(is,Charsets.UTF_8),new TypeToken<List<HashMap<String,Object>>>(){
  }
.getType()));
}

Fixed version (ground truth):
@Override public List<KVDocument> createListFrom(InputStream is){
  return converter.convert((List<Map<String,Object>>)gson.fromJson(new InputStreamReader(is,Charsets.UTF_8),type));
}
Program: 54526
Project: 54526
Buggy source:
@Override public List<KVDocument> createListFromJson(String json){
  return converter.convert((List<Map<String,Object>>)gson.fromJson(json,new TypeToken<List<HashMap<String,Object>>>(){
  }
.getType()));
}

Fixed version (ground truth):
@Override public List<KVDocument> createListFromJson(String json){
  return converter.convert((List<Map<String,Object>>)gson.fromJson(json,type));
}
Program: 54527
Project: 54527
Buggy source:
@Override public List<KVDocument> createListFrom(InputStream is){
  try {
    return converter.convert((List<Map<String,Object>>)mapper.readValue(is,new TypeReference<List<HashMap<String,Object>>>(){
    }
));
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public List<KVDocument> createListFrom(InputStream is){
  try {
    return converter.convert((List<Map<String,Object>>)mapper.readValue(is,typeReference));
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}
Program: 54528
Project: 54528
Buggy source:
@Override public List<KVDocument> createListFromJson(String json){
  try {
    return converter.convert((List<Map<String,Object>>)mapper.readValue(json,new TypeReference<List<HashMap<String,Object>>>(){
    }
));
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str" + json);
  }
}

Fixed version (ground truth):
@Override public List<KVDocument> createListFromJson(String json){
  try {
    return converter.convert((List<Map<String,Object>>)mapper.readValue(json,typeReference));
  }
 catch (  IOException e) {
    throw new RuntimeException("String_Node_Str" + json);
  }
}
Program: 54529
Project: 54529
Buggy source:
@Override protected void shutDown() throws Exception {
  writeDataSource.close();
  systemDataSource.close();
  readOnlyDataSource.close();
}

Fixed version (ground truth):
@Override @SuppressFBWarnings(value="String_Node_Str",justification="String_Node_Str") protected void shutDown() throws Exception {
  writeDataSource.close();
  systemDataSource.close();
  readOnlyDataSource.close();
}
Program: 54530
Project: 54530
Buggy source:
@Override public byte[] get(ResultSet resultSet,int columnIndex) throws SQLException {
  byte[] value=resultSet.getBytes(columnIndex);
  if (resultSet.wasNull()) {
    return null;
  }
  return value;
}

Fixed version (ground truth):
@Override @SuppressFBWarnings(value="String_Node_Str",justification="String_Node_Str") public byte[] get(ResultSet resultSet,int columnIndex) throws SQLException {
  byte[] value=resultSet.getBytes(columnIndex);
  if (resultSet.wasNull()) {
    return null;
  }
  return value;
}
Program: 54531
Project: 54531
Buggy source:
private static String sqlMessage(DataAccessException cause){
  if (cause.getCause() instanceof SQLException) {
    return sqlMessage((SQLException)cause.getCause());
  }
  return cause.getMessage();
}

Fixed version (ground truth):
private static String sqlMessage(DataAccessException cause){
  Throwable causeThroawle=cause.getCause();
  if (causeThroawle instanceof SQLException) {
    return sqlMessage((SQLException)causeThroawle);
  }
  return cause.getMessage();
}
Program: 54532
Project: 54532
Buggy source:
protected void executeSql(DSLContext dsl,String resourcePath,SqlHelper sqlHelper) throws IOException, SQLException {
  InputStream resourceAsStream=getClass().getResourceAsStream(resourcePath);
  if (resourceAsStream == null) {
    throw new SystemException("String_Node_Str" + resourcePath + "String_Node_Str");
  }
  try {
    String statementAsString=CharStreams.toString(new BufferedReader(new InputStreamReader(resourceAsStream,Charset.forName("String_Node_Str"))));
    sqlHelper.executeStatement(dsl,statementAsString,Context.UNKNOWN);
  }
  finally {
    resourceAsStream.close();
  }
}

Fixed version (ground truth):
protected void executeSql(DSLContext dsl,String resourcePath,SqlHelper sqlHelper) throws IOException, SQLException {
  InputStream resourceAsStream=getClass().getClassLoader().getResourceAsStream(resourcePath);
  if (resourceAsStream == null) {
    throw new SystemException("String_Node_Str" + resourcePath + "String_Node_Str");
  }
  try {
    String statementAsString=CharStreams.toString(new BufferedReader(new InputStreamReader(resourceAsStream,Charset.forName("String_Node_Str"))));
    sqlHelper.executeStatement(dsl,statementAsString,Context.UNKNOWN);
  }
  finally {
    resourceAsStream.close();
  }
}
Program: 54533
Project: 54533
Buggy source:
@Override public void deleteDids(MetaDatabase db,MetaCollection col,Collection<Integer> dids){
  Preconditions.checkState(!isClosed(),"String_Node_Str");
  getSqlInterface().getWriteInterface().deleteCollectionDocParts(getDsl(),db.getIdentifier(),col,dids);
}

Fixed version (ground truth):
@Override public void deleteDids(MetaDatabase db,MetaCollection col,Collection<Integer> dids){
  Preconditions.checkState(!isClosed(),"String_Node_Str");
  if (dids.isEmpty()) {
    return;
  }
  getSqlInterface().getWriteInterface().deleteCollectionDocParts(getDsl(),db.getIdentifier(),col,dids);
}
Program: 54534
Project: 54534
Buggy source:
@Locked(exclusive=true) private void loadState() throws OplogManagerPersistException {
  Status<? extends Object> result=retrier.retry(() -> {
    try (ReadOnlyMongodTransaction transaction=connection.openReadOnlyTransaction()){
      Status<FindResult> status=transaction.execute(new Request(OPLOG_DB,null,true,null),FindCommand.INSTANCE,new FindArgument.Builder().setComment(OPLOG_COL).setSlaveOk(true).build());
      if (!status.isOK()) {
        return status;
      }
      Iterator<BsonDocument> batch=status.getResult().getCursor().getFirstBatch();
      if (!batch.hasNext()) {
        lastAppliedHash=0;
        lastAppliedOpTime=OpTime.EPOCH;
      }
 else {
        BsonDocument doc=batch.next();
        BsonDocument subDoc=BsonReaderTool.getDocument(doc,KEY);
        lastAppliedHash=BsonReaderTool.getLong(subDoc,"String_Node_Str");
        BsonDocument opTimeDoc=BsonReaderTool.getDocument(subDoc,"String_Node_Str");
        lastAppliedOpTime=new OpTime(UnsignedInteger.valueOf(BsonReaderTool.getLong(opTimeDoc,"String_Node_Str")),UnsignedInteger.valueOf(BsonReaderTool.getLong(opTimeDoc,"String_Node_Str")));
      }
      return Status.ok();
    }
 catch (    MongoException ex) {
      return Status.from(ex);
    }
  }
);
  if (!result.isOK()) {
    throw new OplogManagerPersistException(result);
  }
}

Fixed version (ground truth):
@Locked(exclusive=true) private void loadState() throws OplogManagerPersistException {
  Status<? extends Object> result=retrier.retry(() -> {
    try (ReadOnlyMongodTransaction transaction=connection.openReadOnlyTransaction()){
      Status<FindResult> status=transaction.execute(new Request(OPLOG_DB,null,true,null),FindCommand.INSTANCE,new FindArgument.Builder().setComment(OPLOG_COL).setSlaveOk(true).build());
      if (!status.isOK()) {
        return status;
      }
      Iterator<BsonDocument> batch=status.getResult().getCursor().getFirstBatch();
      if (!batch.hasNext()) {
        lastAppliedHash=0;
        lastAppliedOpTime=OpTime.EPOCH;
      }
 else {
        BsonDocument doc=batch.next();
        BsonDocument subDoc=BsonReaderTool.getDocument(doc,KEY);
        lastAppliedHash=BsonReaderTool.getLong(subDoc,"String_Node_Str");
        BsonDocument opTimeDoc=BsonReaderTool.getDocument(subDoc,"String_Node_Str");
        lastAppliedOpTime=new OpTime(UnsignedInteger.valueOf(BsonReaderTool.getLong(opTimeDoc,"String_Node_Str")),UnsignedInteger.valueOf(BsonReaderTool.getLong(opTimeDoc,"String_Node_Str")));
      }
      return Status.ok();
    }
 catch (    MongoException ex) {
      return Status.from(ex);
    }
  }
);
  if (!result.isOK()) {
    throw new OplogManagerPersistException(result.getErrorCode(),result.getErrorMsg());
  }
}
Program: 54535
Project: 54535
Buggy source:
public OplogManagerPersistException(Status<?> originalStatus){
  this.originalStatus=originalStatus;
}

Fixed version (ground truth):
public OplogManagerPersistException(ErrorCode errorCode,String errorMsg){
  this.errorCode=errorCode;
  this.errorMsg=errorMsg;
}
Program: 54536
Project: 54536
Buggy source:
@Locked(exclusive=true) private void storeState(long hash,OpTime opTime) throws OplogManagerPersistException {
  Preconditions.checkState(isRunning(),"String_Node_Str");
  Status<?> result=retrier.retry(() -> {
    try (WriteMongodTransaction transaction=connection.openWriteTransaction()){
      Status<Long> deleteResult=transaction.execute(new Request(OPLOG_DB,null,true,null),DeleteCommand.INSTANCE,new DeleteArgument.Builder(OPLOG_COL).addStatement(new DeleteStatement(DOC_QUERY,false)).build());
      if (!deleteResult.isOK()) {
        return deleteResult;
      }
      Status<InsertResult> insertResult=transaction.execute(new Request("String_Node_Str",null,true,null),InsertCommand.INSTANCE,new InsertArgument.Builder("String_Node_Str").addDocument(new BsonDocumentBuilder().appendUnsafe(KEY,new BsonDocumentBuilder().appendUnsafe("String_Node_Str",newLong(hash)).appendUnsafe("String_Node_Str",new BsonDocumentBuilder().appendUnsafe("String_Node_Str",newLong(opTime.getSecs().longValue())).appendUnsafe("String_Node_Str",newLong(opTime.getTerm().longValue())).build()).build()).build()).build());
      if (insertResult.isOK() && insertResult.getResult().getN() != 1) {
        return Status.from(ErrorCode.OPERATION_FAILED,"String_Node_Str");
      }
      return insertResult;
    }
   }
);
  if (!result.isOK()) {
    throw new OplogManagerPersistException(result);
  }
}

Fixed version (ground truth):
@Locked(exclusive=true) private void storeState(long hash,OpTime opTime) throws OplogManagerPersistException {
  Preconditions.checkState(isRunning(),"String_Node_Str");
  Status<?> result=retrier.retry(() -> {
    try (WriteMongodTransaction transaction=connection.openWriteTransaction()){
      Status<Long> deleteResult=transaction.execute(new Request(OPLOG_DB,null,true,null),DeleteCommand.INSTANCE,new DeleteArgument.Builder(OPLOG_COL).addStatement(new DeleteStatement(DOC_QUERY,false)).build());
      if (!deleteResult.isOK()) {
        return deleteResult;
      }
      Status<InsertResult> insertResult=transaction.execute(new Request("String_Node_Str",null,true,null),InsertCommand.INSTANCE,new InsertArgument.Builder("String_Node_Str").addDocument(new BsonDocumentBuilder().appendUnsafe(KEY,new BsonDocumentBuilder().appendUnsafe("String_Node_Str",newLong(hash)).appendUnsafe("String_Node_Str",new BsonDocumentBuilder().appendUnsafe("String_Node_Str",newLong(opTime.getSecs().longValue())).appendUnsafe("String_Node_Str",newLong(opTime.getTerm().longValue())).build()).build()).build()).build());
      if (insertResult.isOK() && insertResult.getResult().getN() != 1) {
        return Status.from(ErrorCode.OPERATION_FAILED,"String_Node_Str");
      }
      return insertResult;
    }
   }
);
  if (!result.isOK()) {
    throw new OplogManagerPersistException(result.getErrorCode(),result.getErrorMsg());
  }
}
Program: 54539
Project: 54539
Buggy source:
@Override public KVDocument createFrom(InputStream is){
  return converter.convert(gson.fromJson(new InputStreamReader(is),new HashMap<String,Object>().getClass()));
}

Fixed version (ground truth):
@Override public KVDocument createFrom(InputStream is){
  return converter.convert(gson.fromJson(new InputStreamReader(is,Charsets.UTF_8),sampleClass.getClass()));
}
Program: 54540
Project: 54540
Buggy source:
@Override public KVDocument createFromJson(String json){
  return converter.convert(gson.fromJson(json,new HashMap<String,Object>().getClass()));
}

Fixed version (ground truth):
@Override public KVDocument createFromJson(String json){
  return converter.convert(gson.fromJson(json,sampleClass.getClass()));
}
Program: 54541
Project: 54541
Buggy source:
@Override public List<KVDocument> createListFrom(InputStream is){
  return converter.convert((List<Map<String,Object>>)gson.fromJson(new InputStreamReader(is),new TypeToken<List<HashMap<String,Object>>>(){
  }
.getType()));
}

Fixed version (ground truth):
@Override public List<KVDocument> createListFrom(InputStream is){
  return converter.convert((List<Map<String,Object>>)gson.fromJson(new InputStreamReader(is,Charsets.UTF_8),new TypeToken<List<HashMap<String,Object>>>(){
  }
.getType()));
}
Program: 54542
Project: 54542
Buggy source:
private boolean isSpecialObject(Map<String,Object> map){
  if (map != null && map.keySet().size() == 1) {
    String key=map.keySet().iterator().next();
    if (key.startsWith("String_Node_Str") && map.get(key) != null) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean isSpecialObject(Map<String,Object> map){
  if (map != null && map.entrySet().size() == 1) {
    Entry<String,Object> next=map.entrySet().iterator().next();
    String key=next.getKey();
    Object value=next.getValue();
    if (key.startsWith("String_Node_Str") && value != null) {
      return true;
    }
  }
  return false;
}
Program: 54543
Project: 54543
Buggy source:
private KVValue<?> buildSpecialObject(Map<String,Object> map){
  String key=map.keySet().iterator().next();
  Object value=map.get(key);
  if ("String_Node_Str".equals(key) && value instanceof String) {
    return new ByteArrayKVMongoObjectId(HexUtils.hex2Bytes((String)value));
  }
  if ("String_Node_Str".equals(key)) {
    return parseDate(key,value);
  }
  throw new RuntimeException("String_Node_Str" + key);
}

Fixed version (ground truth):
private KVValue<?> buildSpecialObject(Map<String,Object> map){
  Entry<String,Object> first=map.entrySet().iterator().next();
  String key=first.getKey();
  Object value=first.getValue();
  if ("String_Node_Str".equals(key) && value instanceof String) {
    return new ByteArrayKVMongoObjectId(HexUtils.hex2Bytes((String)value));
  }
  if ("String_Node_Str".equals(key)) {
    return parseDate(key,value);
  }
  throw new RuntimeException("String_Node_Str" + key);
}
Program: 54544
Project: 54544
Buggy source:
@Benchmark @Fork(value=5) @BenchmarkMode(value=Mode.Throughput) @Warmup(iterations=3) @Measurement(iterations=10) public void benchmarkTranslate(TranslateState state,Blackhole blackhole){
  MvccMetainfoRepository mvccMetainfoRepository=new MvccMetainfoRepository(InitialView);
  MutableMetaSnapshot mutableSnapshot;
  try (SnapshotStage snapshot=mvccMetainfoRepository.startSnapshotStage()){
    mutableSnapshot=snapshot.createMutableSnapshot();
  }
   MutableMetaDatabase db=mutableSnapshot.getMetaDatabaseByName(DB1);
  D2RTranslator translator=new D2RTranslatorStack(tableRefFactory,identifierFactory,ridGenerator,db,db.getMetaCollectionByName(COLL1));
  for (  KVDocument doc : state.document) {
    translator.translate(doc);
  }
  blackhole.consume(translator.getCollectionDataAccumulator());
}

Fixed version (ground truth):
@Benchmark @Fork(value=5) @BenchmarkMode(value=Mode.Throughput) @Warmup(iterations=3) @Measurement(iterations=10) public void benchmarkTranslate(TranslateState state,Blackhole blackhole){
  MvccMetainfoRepository mvccMetainfoRepository=new MvccMetainfoRepository(initialView);
  MutableMetaSnapshot mutableSnapshot;
  try (SnapshotStage snapshot=mvccMetainfoRepository.startSnapshotStage()){
    mutableSnapshot=snapshot.createMutableSnapshot();
  }
   MutableMetaDatabase db=mutableSnapshot.getMetaDatabaseByName(DB1);
  D2RTranslator translator=new D2RTranslatorStack(tableRefFactory,identifierFactory,ridGenerator,db,db.getMetaCollectionByName(COLL1));
  for (  KVDocument doc : state.document) {
    translator.translate(doc);
  }
  blackhole.consume(translator.getCollectionDataAccumulator());
}
Program: 54547
Project: 54547
Buggy source:
public static void main(String[] args){
  MvccMetainfoRepository mvccMetainfoRepository=new MvccMetainfoRepository(InitialView);
  AtomicLong cont=new AtomicLong(0);
  Stopwatch timer=Stopwatch.createUnstarted();
  SimpleDocumentFeed feed=new SimpleDocumentFeed(1000000);
  feed.getFeed("String_Node_Str").forEach(doc -> {
    timer.start();
    executeMetaOperation(mvccMetainfoRepository,(mutableSnapshot) -> {
      MutableMetaDatabase db=mutableSnapshot.getMetaDatabaseByName(DB1);
      D2RTranslator translator=new D2RTranslatorStack(new TableRefFactoryImpl(),new IdentifierFactoryImpl(new MockIdentifierInterface()),new InMemoryRidGenerator(),db,db.getMetaCollectionByName(COLL1));
      translator.translate(doc);
      for (      DocPartData table : translator.getCollectionDataAccumulator().orderedDocPartData()) {
        cont.addAndGet(table.rowCount());
      }
    }
);
    timer.stop();
  }
);
  long elapsed=timer.elapsed(TimeUnit.MICROSECONDS);
  System.out.println("String_Node_Str" + feed.datasize / (1024 * 1024) + "String_Node_Str");
  System.out.println("String_Node_Str" + feed.documents);
  System.out.println("String_Node_Str" + cont);
  System.out.println("String_Node_Str" + elapsed + "String_Node_Str");
  System.out.println("String_Node_Str" + ((double)elapsed / feed.documents) + "String_Node_Str");
  System.out.println("String_Node_Str" + (feed.documents / (double)elapsed * 1000000) + "String_Node_Str");
}

Fixed version (ground truth):
public static void main(String[] args){
  MvccMetainfoRepository mvccMetainfoRepository=new MvccMetainfoRepository(initialView);
  AtomicLong cont=new AtomicLong(0);
  Stopwatch timer=Stopwatch.createUnstarted();
  SimpleDocumentFeed feed=new SimpleDocumentFeed(1000000);
  feed.getFeed("String_Node_Str").forEach(doc -> {
    timer.start();
    executeMetaOperation(mvccMetainfoRepository,(mutableSnapshot) -> {
      MutableMetaDatabase db=mutableSnapshot.getMetaDatabaseByName(DB1);
      D2RTranslator translator=new D2RTranslatorStack(new TableRefFactoryImpl(),new IdentifierFactoryImpl(new MockIdentifierInterface()),new InMemoryRidGenerator(),db,db.getMetaCollectionByName(COLL1));
      translator.translate(doc);
      for (      DocPartData table : translator.getCollectionDataAccumulator().orderedDocPartData()) {
        cont.addAndGet(table.rowCount());
      }
    }
);
    timer.stop();
  }
);
  long elapsed=timer.elapsed(TimeUnit.MICROSECONDS);
  System.out.println("String_Node_Str" + feed.datasize / (1024 * 1024) + "String_Node_Str");
  System.out.println("String_Node_Str" + feed.documents);
  System.out.println("String_Node_Str" + cont);
  System.out.println("String_Node_Str" + elapsed + "String_Node_Str");
  System.out.println("String_Node_Str" + ((double)elapsed / feed.documents) + "String_Node_Str");
  System.out.println("String_Node_Str" + (feed.documents / (double)elapsed * 1000000) + "String_Node_Str");
}
Program: 54548
Project: 54548
Buggy source:
private static String getDocument(String name){
  try (InputStream is=SimpleDocumentFeed.class.getClassLoader().getResourceAsStream(name)){
    try (BufferedReader reader=new BufferedReader(new InputStreamReader(is))){
      StringBuffer sb=new StringBuffer();
      String line=null;
      while ((line=reader.readLine()) != null) {
        sb.append(line);
      }
      return sb.toString();
    }
   }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
private static String getDocument(String name){
  try (InputStream is=SimpleDocumentFeed.class.getClassLoader().getResourceAsStream(name)){
    try (BufferedReader reader=new BufferedReader(new InputStreamReader(is,Charsets.UTF_8))){
      StringBuffer sb=new StringBuffer();
      String line=null;
      while ((line=reader.readLine()) != null) {
        sb.append(line);
      }
      return sb.toString();
    }
   }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}
Program: 54550
Project: 54550
Buggy source:
private void ChainConverterFactory(NameConverterFactory... nameConverterFactories){
  this.converterFactories=nameConverterFactories;
}

Fixed version (ground truth):
private void ChainConverterFactory(NameConverter... nameConverterFactories){
  this.converters=createConverters(nameConverterFactories);
}
Program: 54551
Project: 54551
Buggy source:
private String generateUniqueIdentifier(NameChain nameChain,IdentifierChecker identifierChecker,String extraImmutableName){
  final Instant beginInstant=Instant.now();
  final int maxSize=identifierConstraints.identifierMaxSize();
  String lastCollision=null;
  ChainConverterFactory chainConverterFactory=ChainConverterFactory.straight;
  Counter counter=new Counter();
  String identifier=buildIdentifier(nameChain,chainConverterFactory.createConverters(),maxSize,counter,identifierChecker,extraImmutableName);
  if (identifier.length() <= maxSize && identifierChecker.isUnique(identifier)) {
    return identifier;
  }
  if (identifier.length() <= maxSize) {
    lastCollision=identifier;
  }
  ChainConverterFactory counterChainConverterFactory=ChainConverterFactory.counter;
  NameConverter[] randomConverters=counterChainConverterFactory.createConverters();
  while (ChronoUnit.SECONDS.between(beginInstant,Instant.now()) < MAX_GENERATION_TIME) {
    identifier=buildIdentifier(nameChain,randomConverters,maxSize,counter,identifierChecker,extraImmutableName);
    if (identifier.length() > maxSize) {
      throw new SystemException("String_Node_Str");
    }
    if (identifierChecker.isUnique(identifier)) {
      return identifier;
    }
    lastCollision=identifier;
    counter.increment();
  }
  if (lastCollision != null) {
    throw new SystemException("String_Node_Str" + lastCollision + "String_Node_Str"+ nameChain);
  }
  throw new SystemException("String_Node_Str" + nameChain);
}

Fixed version (ground truth):
private String generateUniqueIdentifier(NameChain nameChain,IdentifierChecker identifierChecker,String extraImmutableName){
  final Instant beginInstant=Instant.now();
  final int maxSize=identifierConstraints.identifierMaxSize();
  String lastCollision=null;
  ChainConverterFactory straightConverterFactory=ChainConverterFactory.straight;
  Counter counter=new Counter();
  String identifier=buildIdentifier(nameChain,straightConverterFactory.getConverters(),maxSize,counter,identifierChecker,extraImmutableName);
  if (identifier.length() <= maxSize && identifierChecker.isUnique(identifier)) {
    return identifier;
  }
  if (identifier.length() <= maxSize) {
    lastCollision=identifier;
  }
  ChainConverterFactory counterChainConverterFactory=ChainConverterFactory.counter;
  NameConverter[] counterConverters=counterChainConverterFactory.getConverters();
  while (ChronoUnit.SECONDS.between(beginInstant,Instant.now()) < MAX_GENERATION_TIME) {
    identifier=buildIdentifier(nameChain,counterConverters,maxSize,counter,identifierChecker,extraImmutableName);
    if (identifier.length() > maxSize) {
      throw new SystemException("String_Node_Str");
    }
    if (identifierChecker.isUnique(identifier)) {
      return identifier;
    }
    lastCollision=identifier;
    counter.increment();
  }
  if (lastCollision != null) {
    throw new SystemException("String_Node_Str" + lastCollision + "String_Node_Str"+ nameChain);
  }
  throw new SystemException("String_Node_Str" + nameChain);
}
Program: 54552
Project: 54552
Buggy source:
public NameConverter[] createConverters(){
  NameConverter[] converters=new NameConverter[3];
  converters[0]=converterFactories[0].create();
  converters[1]=converters[0];
  converters[2]=converters[0];
  if (converterFactories.length > 1) {
    if (converterFactories[0] == converterFactories[1]) {
      converters[1]=converters[0];
    }
 else {
      converters[1]=converterFactories[1].create();
    }
    converters[2]=converters[0];
  }
  if (converterFactories.length > 2) {
    if (converterFactories[0] == converterFactories[2]) {
      converters[2]=converters[0];
    }
 else     if (converterFactories[1] == converterFactories[2]) {
      converters[2]=converters[1];
    }
 else {
      converters[2]=converterFactories[2].create();
    }
  }
  return converters;
}

Fixed version (ground truth):
private NameConverter[] createConverters(NameConverter[] converterFactories){
  NameConverter[] converters=new NameConverter[3];
  converters[0]=converterFactories[0];
  converters[1]=converters[0];
  converters[2]=converters[0];
  if (converterFactories.length > 1) {
    if (converterFactories[0] == converterFactories[1]) {
      converters[1]=converters[0];
    }
 else {
      converters[1]=converterFactories[1];
    }
    converters[2]=converters[0];
  }
  if (converterFactories.length > 2) {
    if (converterFactories[0] == converterFactories[2]) {
      converters[2]=converters[0];
    }
 else     if (converterFactories[1] == converterFactories[2]) {
      converters[2]=converters[1];
    }
 else {
      converters[2]=converterFactories[2];
    }
  }
  return converters;
}
Program: 54553
Project: 54553
Buggy source:
private void addValueToDocPartRow(Map<Integer,Map<String,List<KVValue<?>>>> currentDocPartRow,TableRef tableRef,Integer pid,Integer seq,KVValue<?> value){
  if (seq == null) {
    setDocPartRowValue(currentDocPartRow,tableRef,pid,seq,ImmutableList.of(value));
  }
 else {
    addToDocPartRow(currentDocPartRow,tableRef,pid,seq,value);
  }
}

Fixed version (ground truth):
private void addValueToDocPartRow(Map<Integer,Map<String,List<KVValue<?>>>> currentDocPartRow,TableRef tableRef,Integer pid,Integer seq,KVValue<?> value){
  if (seq == null) {
    setDocPartRowValue(currentDocPartRow,tableRef,pid,null,ImmutableList.of(value));
  }
 else {
    addToDocPartRow(currentDocPartRow,tableRef,pid,seq,value);
  }
}
Program: 54554
Project: 54554
Buggy source:
@Override public R next(){
  idx++;
  return null;
}

Fixed version (ground truth):
@Override public R next(){
  if (hasNext()) {
    idx++;
    return null;
  }
  throw new NoSuchElementException();
}
Program: 54555
Project: 54555
Buggy source:
private static void escape(String nonEscaped,StringBuilder appender){
  if (!needsEscape(nonEscaped)) {
    appender.append(nonEscaped);
    return;
  }
  appender.ensureCapacity(nonEscaped.length() + 16);
  int lenght=nonEscaped.length();
  int i=0;
  while (i < lenght) {
    char c=nonEscaped.charAt(i);
switch (c) {
case ROW_DELIMETER:
case COLUMN_DELIMETER:
case '\\':
case '\r':
      appender.append('\\');
    break;
default :
}
appender.append(c);
i++;
}
}

Fixed version (ground truth):
private static void escape(String nonEscaped,StringBuilder appender){
  if (!needsEscape(nonEscaped)) {
    appender.append(nonEscaped);
    return;
  }
  appender.ensureCapacity(nonEscaped.length() + 16);
  int lenght=nonEscaped.length();
  int i=0;
  while (i < lenght) {
    char c=nonEscaped.charAt(i);
switch (c) {
case ROW_DELIMETER:
case COLUMN_DELIMETER:
case '\\':
case '\r':
      appender.append('\\');
    break;
default :
  break;
}
appender.append(c);
i++;
}
}
Program: 54556
Project: 54556
Buggy source:
public KVDocument build(){
  KVDocument updatedDocument;
  if (did != null) {
    updatedDocument=buildRoot();
  }
 else {
    updatedDocument=buildRoot();
  }
  clear();
  return updatedDocument;
}

Fixed version (ground truth):
public KVDocument build(){
  KVDocument updatedDocument;
  updatedDocument=buildRoot();
  clear();
  return updatedDocument;
}
Program: 54557
Project: 54557
Buggy source:
@Override public DidCursor getCollectionDidsWithFieldEqualsTo(DSLContext dsl,MetaDatabase metaDatabase,MetaCollection metaCol,MetaDocPart metaDocPart,MetaField metaField,KVValue<?> value) throws SQLException {
}

Fixed version (ground truth):
@Override @SuppressFBWarnings(value={"String_Node_Str","String_Node_Str"},justification="String_Node_Str") public DidCursor getCollectionDidsWithFieldEqualsTo(DSLContext dsl,MetaDatabase metaDatabase,MetaCollection metaCol,MetaDocPart metaDocPart,MetaField metaField,KVValue<?> value) throws SQLException {
}
Program: 54558
Project: 54558
Buggy source:
@Override public DocPartResultBatch getCollectionResultSets(DSLContext dsl,MetaDatabase metaDatabase,MetaCollection metaCollection,Collection<Integer> dids) throws SQLException {
  ArrayList<DocPartResult> result=new ArrayList<>();
  Connection connection=dsl.configuration().connectionProvider().acquire();
  try {
    Iterator<? extends MetaDocPart> metaDocPartIterator=metaCollection.streamContainedMetaDocParts().sorted(TableRefComparator.MetaDocPart.DESC).iterator();
    while (metaDocPartIterator.hasNext()) {
      MetaDocPart metaDocPart=metaDocPartIterator.next();
      String statament=getDocPartStatament(metaDatabase,metaDocPart,dids);
      PreparedStatement preparedStatement=connection.prepareStatement(statament);
      result.add(new ResultSetDocPartResult(metaDataReadInterface,dataTypeProvider,errorHandler,metaDocPart,preparedStatement.executeQuery(),sqlHelper));
    }
  }
  finally {
    dsl.configuration().connectionProvider().release(connection);
  }
  return new DocPartResultBatch(result);
}

Fixed version (ground truth):
@Override @SuppressFBWarnings(value={"String_Node_Str","String_Node_Str"},justification="String_Node_Str") public DocPartResultBatch getCollectionResultSets(DSLContext dsl,MetaDatabase metaDatabase,MetaCollection metaCollection,Collection<Integer> dids) throws SQLException {
  ArrayList<DocPartResult> result=new ArrayList<>();
  Connection connection=dsl.configuration().connectionProvider().acquire();
  try {
    Iterator<? extends MetaDocPart> metaDocPartIterator=metaCollection.streamContainedMetaDocParts().sorted(TableRefComparator.MetaDocPart.DESC).iterator();
    while (metaDocPartIterator.hasNext()) {
      MetaDocPart metaDocPart=metaDocPartIterator.next();
      String statament=getDocPartStatament(metaDatabase,metaDocPart,dids);
      PreparedStatement preparedStatement=connection.prepareStatement(statament);
      result.add(new ResultSetDocPartResult(metaDataReadInterface,dataTypeProvider,errorHandler,metaDocPart,preparedStatement.executeQuery(),sqlHelper));
    }
  }
  finally {
    dsl.configuration().connectionProvider().release(connection);
  }
  return new DocPartResultBatch(result);
}
Program: 54559
Project: 54559
Buggy source:
@Override public DidCursor getAllCollectionDids(DSLContext dsl,MetaDatabase metaDatabase,MetaCollection metaCollection) throws SQLException {
  MetaDocPart rootDocPart=metaCollection.getMetaDocPartByTableRef(tableRefFactory.createRoot());
  if (rootDocPart == null) {
    return EmptyDidCursor.INSTANCE;
  }
  String statement=getReadAllCollectionDidsStatement(metaDatabase.getIdentifier(),rootDocPart.getIdentifier());
  Connection connection=dsl.configuration().connectionProvider().acquire();
  try {
    PreparedStatement preparedStatement=connection.prepareStatement(statement);
    return new DefaultDidCursor(errorHandler,preparedStatement.executeQuery());
  }
  finally {
    dsl.configuration().connectionProvider().release(connection);
  }
}

Fixed version (ground truth):
@Override @SuppressFBWarnings(value={"String_Node_Str","String_Node_Str"},justification="String_Node_Str") public DidCursor getAllCollectionDids(DSLContext dsl,MetaDatabase metaDatabase,MetaCollection metaCollection) throws SQLException {
  MetaDocPart rootDocPart=metaCollection.getMetaDocPartByTableRef(tableRefFactory.createRoot());
  if (rootDocPart == null) {
    return EmptyDidCursor.INSTANCE;
  }
  String statement=getReadAllCollectionDidsStatement(metaDatabase.getIdentifier(),rootDocPart.getIdentifier());
  Connection connection=dsl.configuration().connectionProvider().acquire();
  try {
    PreparedStatement preparedStatement=connection.prepareStatement(statement);
    return new DefaultDidCursor(errorHandler,preparedStatement.executeQuery());
  }
  finally {
    dsl.configuration().connectionProvider().release(connection);
  }
}
Program: 54560
Project: 54560
Buggy source:
@Override public int getLastRowIdUsed(@Nonnull DSLContext dsl,@Nonnull MetaDatabase metaDatabase,@Nonnull MetaCollection metaCollection,@Nonnull MetaDocPart metaDocPart){
  String statement=getLastRowIdUsedStatement(metaDatabase,metaDocPart);
  Connection connection=dsl.configuration().connectionProvider().acquire();
  try (PreparedStatement preparedStatement=connection.prepareStatement(statement)){
    ResultSet rs=preparedStatement.executeQuery();
    rs.next();
    int maxId=rs.getInt(1);
    if (rs.wasNull()) {
      return -1;
    }
    return maxId;
  }
 catch (  SQLException ex) {
    throw errorHandler.handleException(Context.FETCH,ex);
  }
 finally {
    dsl.configuration().connectionProvider().release(connection);
  }
}

Fixed version (ground truth):
@Override public int getLastRowIdUsed(DSLContext dsl,MetaDatabase metaDatabase,MetaCollection metaCollection,MetaDocPart metaDocPart){
  String statement=getLastRowIdUsedStatement(metaDatabase,metaDocPart);
  Connection connection=dsl.configuration().connectionProvider().acquire();
  try (PreparedStatement preparedStatement=connection.prepareStatement(statement)){
    try (ResultSet rs=preparedStatement.executeQuery()){
      rs.next();
      int maxId=rs.getInt(1);
      if (rs.wasNull()) {
        return -1;
      }
      return maxId;
    }
   }
 catch (  SQLException ex) {
    throw errorHandler.handleException(Context.FETCH,ex);
  }
 finally {
    dsl.configuration().connectionProvider().release(connection);
  }
}
Program: 54561
Project: 54561
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void setPreparedStatementValue(PreparedStatement preparedStatement,int parameterIndex,FieldType fieldType,KVValue<?> value) throws SQLException {
  DataTypeForKV dataType=dataTypeProvider.getDataType(fieldType);
  Converter converter=dataType.getConverter();
  KVValueConverter valueConverter=dataType.getKVValueConverter();
  SqlBinding sqlBinding=valueConverter.getSqlBinding();
  sqlBinding.set(preparedStatement,parameterIndex,converter.to(value));
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void setPreparedStatementValue(PreparedStatement preparedStatement,int parameterIndex,FieldType fieldType,KVValue<?> value) throws SQLException {
  DataTypeForKV dataType=dataTypeProvider.getDataType(fieldType);
  KVValueConverter valueConverter=dataType.getKVValueConverter();
  Converter converter=dataType.getConverter();
  SqlBinding sqlBinding=valueConverter.getSqlBinding();
  sqlBinding.set(preparedStatement,parameterIndex,converter.to(value));
}