nus-yam/ex-repair huggingface dataset:
Program: 13996
Project: 13996
Buggy source:
public int parseInto(DateTimeParserBucket bucket,String text,int position){
  DateTimeParser[] parsers=iParsers;
  int length=parsers.length;
  Object state=bucket.saveState();
  int bestInvalidPos=position;
  int bestInvalidParser=0;
  int bestValidPos=position;
  int bestValidParser=0;
  for (int i=0; i < length; i++) {
    if (i != 0) {
      bucket.undoChanges(state);
    }
    DateTimeParser parser=parsers[i];
    if (parser == null) {
      if (bestValidPos > position) {
        break;
      }
      return position;
    }
    int parsePos=parser.parseInto(bucket,text,position);
    if (parsePos >= position) {
      if (parsePos >= text.length()) {
        return parsePos;
      }
      if (parsePos > bestValidPos) {
        bestValidPos=parsePos;
        bestValidParser=i;
      }
    }
 else {
      parsePos=~parsePos;
      if (parsePos > bestInvalidPos) {
        bestInvalidPos=parsePos;
        bestInvalidParser=i;
      }
    }
  }
  if (bestValidPos > position) {
    if (bestValidParser == length - 1) {
      return bestValidPos;
    }
    bucket.undoChanges(state);
    return parsers[bestValidParser].parseInto(bucket,text,position);
  }
  if (bestInvalidParser == length - 1) {
    return ~bestInvalidPos;
  }
  bucket.undoChanges(state);
  return parsers[bestInvalidParser].parseInto(bucket,text,position);
}

Fixed version (ground truth):
public int parseInto(final DateTimeParserBucket bucket,final String text,final int position){
  DateTimeParser[] parsers=iParsers;
  int length=parsers.length;
  final Object originalState=bucket.saveState();
  boolean isOptional=false;
  int bestValidPos=position;
  Object bestValidState=null;
  int bestInvalidPos=position;
  for (int i=0; i < length; i++) {
    DateTimeParser parser=parsers[i];
    if (parser == null) {
      if (bestValidPos <= position) {
        return position;
      }
      isOptional=true;
      break;
    }
    int parsePos=parser.parseInto(bucket,text,position);
    if (parsePos >= position) {
      if (parsePos > bestValidPos) {
        if (parsePos >= text.length() || (i + 1) >= length || parsers[i + 1] == null) {
          return parsePos;
        }
        bestValidPos=parsePos;
        bestValidState=bucket.saveState();
      }
    }
 else {
      bucket.undoChanges(originalState);
      if (parsePos < 0) {
        parsePos=~parsePos;
        if (parsePos > bestInvalidPos) {
          bestInvalidPos=parsePos;
        }
      }
    }
  }
  if (bestValidPos > position || (bestValidPos == position && isOptional)) {
    if (bestValidState != null) {
      bucket.undoChanges(bestValidState);
    }
    return bestValidPos;
  }
  return ~bestInvalidPos;
}
Program: 13997
Project: 13997
Buggy source:
/** 
 * Appends a printer and a set of matching parsers. When parsing, the first parser in the list is selected for parsing. If it fails, the next is chosen, and so on. If none of these parsers succeeds, then the failed position of the parser that made the greatest progress is returned. <p> Only the printer is optional. In addtion, it is illegal for any but the last of the parser array elements to be null. If the last element is null, this represents the empty parser. The presence of an empty parser indicates that the entire array of parse formats is optional.
 * @return this DateTimeFormatterBuilder
 * @throws IllegalArgumentException if any parser element but the last is null
 */
public DateTimeFormatterBuilder append(final DateTimePrinter printer,final DateTimeParser[] parsers) throws IllegalArgumentException {
  if (parsers == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int length=parsers.length;
  if (length == 1) {
    return append(printer,parsers[0]);
  }
  DateTimeParser[] copyOfParsers=new DateTimeParser[length];
  int i;
  for (i=0; i < length - 1; i++) {
    if ((copyOfParsers[i]=parsers[i]) == null) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  copyOfParsers[i]=parsers[i];
  return append0(printer,new MatchingParser(iChrono,copyOfParsers));
}

Fixed version (ground truth):
/** 
 * Appends a printer and a set of matching parsers. When parsing, the first parser in the list is selected for parsing. If it fails, the next is chosen, and so on. If none of these parsers succeeds, then the failed position of the parser that made the greatest progress is returned. <p> Only the printer is optional. In addtion, it is illegal for any but the last of the parser array elements to be null. If the last element is null, this represents the empty parser. The presence of an empty parser indicates that the entire array of parse formats is optional.
 * @return this DateTimeFormatterBuilder
 * @throws IllegalArgumentException if any parser element but the last is null
 */
public DateTimeFormatterBuilder append(final DateTimePrinter printer,final DateTimeParser[] parsers) throws IllegalArgumentException {
  if (parsers == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int length=parsers.length;
  if (length == 1) {
    if (parsers[0] == null) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    return append0(printer,parsers[0]);
  }
  DateTimeParser[] copyOfParsers=new DateTimeParser[length];
  int i;
  for (i=0; i < length - 1; i++) {
    if ((copyOfParsers[i]=parsers[i]) == null) {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  copyOfParsers[i]=parsers[i];
  return append0(printer,new MatchingParser(iChrono,copyOfParsers));
}
Program: 13998
Project: 13998
Buggy source:
static String createErrorMessage(final String text,final int errorPos){
  int sampleLen=errorPos + 20;
  String sampleText;
  if (text.length() <= sampleLen) {
    sampleText=text;
  }
 else {
    sampleText=text.substring(0,sampleLen).concat("String_Node_Str");
  }
  if (errorPos <= 0) {
    return "String_Node_Str" + sampleText + '"';
  }
  if (errorPos >= text.length()) {
    return "String_Node_Str" + sampleText + "String_Node_Str";
  }
  return "String_Node_Str" + sampleText + "String_Node_Str"+ sampleText.substring(errorPos)+ '"';
}

Fixed version (ground truth):
static String createErrorMessage(final String text,final int errorPos){
  int sampleLen=errorPos + 20;
  String sampleText;
  if (text.length() <= sampleLen + 3) {
    sampleText=text;
  }
 else {
    sampleText=text.substring(0,sampleLen).concat("String_Node_Str");
  }
  if (errorPos <= 0) {
    return "String_Node_Str" + sampleText + '"';
  }
  if (errorPos >= text.length()) {
    return "String_Node_Str" + sampleText + "String_Node_Str";
  }
  return "String_Node_Str" + sampleText + "String_Node_Str"+ sampleText.substring(errorPos)+ '"';
}
Program: 13999
Project: 13999
Buggy source:
private void makeGraphCall(){
  Session session=Session.getActiveSession();
  Request.Callback graphCallback=new Request.Callback(){
    @Override public void onCompleted(    Response response){
      if (graphContext != null) {
        if (response.getError() != null) {
          graphContext.error(response.getError().getErrorMessage());
        }
 else {
          GraphObject graphObject=response.getGraphObject();
          graphContext.success(graphObject.getInnerJSONObject());
        }
        graphPath=null;
        graphContext=null;
      }
    }
  }
;
  try {
    graphPath=URLDecoder.decode(graphPath,"String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  String[] urlParts=graphPath.split("String_Node_Str");
  String graphAction=urlParts[0];
  Request graphRequest=Request.newGraphPathRequest(null,graphAction,graphCallback);
  Bundle params=graphRequest.getParameters();
  if (urlParts.length > 1) {
    String[] queries=urlParts[1].split("String_Node_Str");
    for (    String query : queries) {
      int splitPoint=query.indexOf("String_Node_Str");
      if (splitPoint > 0) {
        String key=query.substring(0,splitPoint);
        String value=query.substring(splitPoint + 1,query.length());
        params.putString(key,value);
      }
    }
  }
  params.putString("String_Node_Str",session.getAccessToken());
  graphRequest.setParameters(params);
  graphRequest.executeAsync();
}

Fixed version (ground truth):
private void makeGraphCall(){
  Session session=Session.getActiveSession();
  Request.Callback graphCallback=new Request.Callback(){
    @Override public void onCompleted(    Response response){
      if (graphContext != null) {
        if (response.getError() != null) {
          graphContext.error(getErrorResponse(response.getError()));
        }
 else {
          GraphObject graphObject=response.getGraphObject();
          graphContext.success(graphObject.getInnerJSONObject());
        }
        graphPath=null;
        graphContext=null;
      }
    }
  }
;
  try {
    graphPath=URLDecoder.decode(graphPath,"String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  String[] urlParts=graphPath.split("String_Node_Str");
  String graphAction=urlParts[0];
  Request graphRequest=Request.newGraphPathRequest(null,graphAction,graphCallback);
  Bundle params=graphRequest.getParameters();
  if (urlParts.length > 1) {
    String[] queries=urlParts[1].split("String_Node_Str");
    for (    String query : queries) {
      int splitPoint=query.indexOf("String_Node_Str");
      if (splitPoint > 0) {
        String key=query.substring(0,splitPoint);
        String value=query.substring(splitPoint + 1,query.length());
        params.putString(key,value);
      }
    }
  }
  params.putString("String_Node_Str",session.getAccessToken());
  graphRequest.setParameters(params);
  graphRequest.executeAsync();
}
Program: 14000
Project: 14000
Buggy source:
@Override public void onCompleted(Response response){
  if (graphContext != null) {
    if (response.getError() != null) {
      graphContext.error(response.getError().getErrorMessage());
    }
 else {
      GraphObject graphObject=response.getGraphObject();
      graphContext.success(graphObject.getInnerJSONObject());
    }
    graphPath=null;
    graphContext=null;
  }
}

Fixed version (ground truth):
@Override public void onCompleted(Response response){
  if (graphContext != null) {
    if (response.getError() != null) {
      graphContext.error(getErrorResponse(response.getError()));
    }
 else {
      GraphObject graphObject=response.getGraphObject();
      graphContext.success(graphObject.getInnerJSONObject());
    }
    graphPath=null;
    graphContext=null;
  }
}
Program: 14001
Project: 14001
Buggy source:
private void getUserInfo(final Session session){
  if (cordova != null) {
    Request.newMeRequest(session,new Request.GraphUserCallback(){
      @Override public void onCompleted(      GraphUser user,      Response response){
        if (loginContext != null) {
          GraphObject graphObject=response.getGraphObject();
          Log.d(TAG,"String_Node_Str" + graphObject.getInnerJSONObject().toString());
          userID=user.getId();
          loginContext.success(getResponse());
          loginContext=null;
        }
      }
    }
).executeAsync();
  }
}

Fixed version (ground truth):
private void getUserInfo(final Session session){
  if (cordova != null) {
    Request.newMeRequest(session,new Request.GraphUserCallback(){
      @Override public void onCompleted(      GraphUser user,      Response response){
        if (loginContext != null) {
          if (response.getError() != null) {
            loginContext.error(getErrorResponse(response.getError()));
          }
 else {
            GraphObject graphObject=response.getGraphObject();
            userID=user.getId();
            loginContext.success(getResponse());
          }
          loginContext=null;
        }
      }
    }
).executeAsync();
  }
}
Program: 14002
Project: 14002
Buggy source:
@Override public void onComplete(Bundle values,FacebookException exception){
  String errMsg;
  if (exception != null) {
    if (exception instanceof FacebookOperationCanceledException) {
      errMsg="String_Node_Str";
      Log.e(TAG,errMsg);
      showDialogContext.error(errMsg);
    }
 else     if (exception instanceof FacebookDialogException) {
      errMsg="String_Node_Str" + exception.getMessage();
      Log.e(TAG,errMsg);
      showDialogContext.error(errMsg);
    }
 else {
      errMsg="String_Node_Str" + exception.getMessage();
      Log.e(TAG,errMsg);
      showDialogContext.error(errMsg);
    }
  }
 else {
    if (values.size() > 0) {
      JSONObject response=new JSONObject();
      try {
        Set<String> keys=values.keySet();
        for (        String key : keys) {
          response.put(key,values.get(key));
        }
      }
 catch (      JSONException e) {
        e.printStackTrace();
      }
      showDialogContext.success(response);
    }
 else {
      errMsg="String_Node_Str";
      Log.e(TAG,errMsg);
      showDialogContext.error(errMsg);
    }
  }
}

Fixed version (ground truth):
@Override public void onComplete(Bundle values,FacebookException exception){
  if (exception != null) {
    String errMsg="String_Node_Str" + exception.getMessage();
    if (exception instanceof FacebookOperationCanceledException) {
      errMsg="String_Node_Str";
    }
 else     if (exception instanceof FacebookDialogException) {
      errMsg="String_Node_Str" + exception.getMessage();
    }
 else     if (exception instanceof FacebookServiceException) {
      FacebookRequestError error=((FacebookServiceException)exception).getRequestError();
      if (error.getErrorCode() == 4201) {
        errMsg="String_Node_Str";
      }
    }
    Log.e(TAG,errMsg);
    showDialogContext.error(errMsg);
  }
 else {
    if (values.size() > 0) {
      JSONObject response=new JSONObject();
      try {
        Set<String> keys=values.keySet();
        for (        String key : keys) {
          response.put(key,values.get(key));
        }
      }
 catch (      JSONException e) {
        e.printStackTrace();
      }
      showDialogContext.success(response);
    }
 else {
      Log.e(TAG,"String_Node_Str");
      showDialogContext.error("String_Node_Str");
    }
  }
}
Program: 14004
Project: 14004
Buggy source:
@Override public void onPageStarted(WebView view,String url,Bitmap favicon){
  Uri uri=Uri.parse(url);
  Log.d(TAG,url);
  String uriFragment=uri.getFragment();
  if (uriFragment != null && uriFragment.startsWith("String_Node_Str")) {
    try {
      String[] params=uriFragment.split("String_Node_Str");
      String[] accessTokenParam=params[0].split("String_Node_Str");
      String accessToken=accessTokenParam[1];
      AccessGrant accessGrant=new AccessGrant(accessToken);
      Connection<Facebook> connection=connectionFactory.createConnection(accessGrant);
      try {
        connectionRepository.addConnection(connection);
      }
 catch (      DuplicateConnectionException e) {
      }
    }
 catch (    Exception e) {
    }
    displayFacebookOptions();
  }
  if (uri.getQueryParameter("String_Node_Str") != null) {
    CharSequence errorReason=uri.getQueryParameter("String_Node_Str").replace("String_Node_Str","String_Node_Str");
    Toast.makeText(getApplicationContext(),errorReason,Toast.LENGTH_LONG).show();
    displayFacebookOptions();
  }
}

Fixed version (ground truth):
@Override public void onPageStarted(WebView view,String url,Bitmap favicon){
  Uri uri=Uri.parse(url);
  Log.d(TAG,url);
  AccessGrant accessGrant=createAccessGrantFromUriFragment(uri.getFragment());
  if (accessGrant != null) {
    new CreateConnectionTask().execute(accessGrant);
  }
  if (uri.getQueryParameter("String_Node_Str") != null) {
    CharSequence errorReason=uri.getQueryParameter("String_Node_Str").replace("String_Node_Str","String_Node_Str");
    Toast.makeText(getApplicationContext(),errorReason,Toast.LENGTH_LONG).show();
    displayFacebookMenuOptions();
  }
}
Program: 14005
Project: 14005
Buggy source:
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWebView().getSettings().setJavaScriptEnabled(true);
  getWebView().setWebViewClient(new FacebookOAuthWebViewClient());
  this.connectionRepository=getApplicationContext().getConnectionRepository();
  this.connectionFactory=getApplicationContext().getFacebookConnectionFactory();
}

Fixed version (ground truth):
@SuppressLint("String_Node_Str") @Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  getWebView().getSettings().setJavaScriptEnabled(true);
  getWebView().setWebViewClient(new FacebookOAuthWebViewClient());
  this.connectionRepository=getApplicationContext().getConnectionRepository();
  this.connectionFactory=getApplicationContext().getFacebookConnectionFactory();
}
Program: 14006
Project: 14006
Buggy source:
public Query(Connection connection,String queryText,String name,boolean returnGeneratedKeys){
  this.connection=connection;
  this.name=name;
  this.returnGeneratedKeys=returnGeneratedKeys;
  this.setColumnMappings(connection.getSql2o().getDefaultColumnMappings());
  this.caseSensitive=connection.getSql2o().isDefaultCaseSensitive();
  paramNameToIdxMap=new HashMap<>();
  parsedQuery=connection.getSql2o().getSqlParameterParsingStrategy().parseSql(queryText,paramNameToIdxMap);
  try {
    if (returnGeneratedKeys) {
      statement=connection.getJdbcConnection().prepareStatement(parsedQuery,Statement.RETURN_GENERATED_KEYS);
    }
 else {
      statement=connection.getJdbcConnection().prepareStatement(parsedQuery);
    }
  }
 catch (  SQLException ex) {
    throw new Sql2oException(String.format("String_Node_Str",ex.getMessage()),ex);
  }
  connection.registerStatement(statement);
}

Fixed version (ground truth):
public Query(Connection connection,String queryText,String name,boolean returnGeneratedKeys){
  this.connection=connection;
  this.name=name;
  this.returnGeneratedKeys=returnGeneratedKeys;
  this.setColumnMappings(connection.getSql2o().getDefaultColumnMappings());
  this.caseSensitive=connection.getSql2o().isDefaultCaseSensitive();
  paramNameToIdxMap=new HashMap<>();
  parsedQuery=connection.getSql2o().getQuirks().getSqlParameterParsingStrategy().parseSql(queryText,paramNameToIdxMap);
  try {
    if (returnGeneratedKeys) {
      statement=connection.getJdbcConnection().prepareStatement(parsedQuery,Statement.RETURN_GENERATED_KEYS);
    }
 else {
      statement=connection.getJdbcConnection().prepareStatement(parsedQuery);
    }
  }
 catch (  SQLException ex) {
    throw new Sql2oException(String.format("String_Node_Str",ex.getMessage()),ex);
  }
  connection.registerStatement(statement);
}
Program: 14007
Project: 14007
Buggy source:
/** 
 * Reproduce issue #142 (https://github.com/aaberg/sql2o/issues/142)
 */
@Test public void testIgnoreSqlComments(){
class ThePojo {
    public int id;
    public int intval;
    public String strval;
  }
  String createSql="String_Node_Str";
  String insertQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  String fetchQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  try (Connection connection=sql2o.open()){
    connection.createQuery(createSql).executeUpdate();
    for (int idx=0; idx < 100; idx++) {
      int intval=idx % 10;
      connection.createQuery(insertQuery).addParameter("String_Node_Str",idx).addParameter("String_Node_Str",intval).addParameter("String_Node_Str","String_Node_Str" + idx).executeUpdate();
    }
    List<ThePojo> resultList=connection.createQuery(fetchQuery).addParameter("String_Node_Str",5).executeAndFetch(ThePojo.class);
    assertEquals(10,resultList.size());
  }
 }

Fixed version (ground truth):
/** 
 * Reproduce issue #142 (https://github.com/aaberg/sql2o/issues/142)
 */
@Test public void testIgnoreSqlComments(){
class ThePojo {
    public int id;
    public int intval;
    public String strval;
  }
  String createSql="String_Node_Str";
  String insertQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  String fetchQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  try (Connection connection=sql2o.open()){
    connection.createQuery(createSql).executeUpdate();
    for (int idx=0; idx < 100; idx++) {
      int intval=idx % 10;
      connection.createQuery(insertQuery).addParameter("String_Node_Str",idx).addParameter("String_Node_Str",intval).addParameter("String_Node_Str","String_Node_Str" + idx).executeUpdate();
    }
    List<ThePojo> resultList=connection.createQuery(fetchQuery).addParameter("String_Node_Str",5).executeAndFetch(ThePojo.class);
    assertEquals(10,resultList.size());
  }
 }
Program: 14008
Project: 14008
Buggy source:
public Row(Map<String,Integer> columnNameToIdxMap,boolean isCaseSensitive,Quirks quirks){
  this.columnNameToIdxMap=columnNameToIdxMap;
  this.isCaseSensitive=isCaseSensitive;
  this.quirks=quirks;
  this.values=new Object[columnNameToIdxMap.size()];
}

Fixed version (ground truth):
public Row(Map<String,Integer> columnNameToIdxMap,int columnCnt,boolean isCaseSensitive,Quirks quirks){
  this.columnNameToIdxMap=columnNameToIdxMap;
  this.isCaseSensitive=isCaseSensitive;
  this.quirks=quirks;
  this.values=new Object[columnCnt];
}
Program: 14009
Project: 14009
Buggy source:
@Override protected Row readNext() throws SQLException {
  Row row=new Row(columnNameToIdxMap,isCaseSensitive,this.quirks);
  for (  Column column : columns) {
    row.addValue(column.getIndex(),quirks.getRSVal(rs,column.getIndex() + 1));
  }
  return row;
}

Fixed version (ground truth):
@Override protected Row readNext() throws SQLException {
  Row row=new Row(columnNameToIdxMap,columns.size(),isCaseSensitive,this.quirks);
  for (  Column column : columns) {
    row.addValue(column.getIndex(),quirks.getRSVal(rs,column.getIndex() + 1));
  }
  return row;
}
Program: 14010
Project: 14010
Buggy source:
@SuppressWarnings("String_Node_Str") public ResultSetHandler<T> newResultSetHandler(final ResultSetMetaData meta) throws SQLException {
  if (FeatureDetector.isCachePojoMetaDataEnabled()) {
    StringBuilder stringBuilder=new StringBuilder();
    for (int i=1; i <= meta.getColumnCount(); i++) {
      stringBuilder.append(quirks.getColumnName(meta,i)).append("String_Node_Str");
    }
    return c.get(new Key(stringBuilder.toString(),this),meta);
  }
 else {
    return newResultSetHandler0(meta);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public ResultSetHandler<T> newResultSetHandler(final ResultSetMetaData meta) throws SQLException {
  StringBuilder stringBuilder=new StringBuilder();
  for (int i=1; i <= meta.getColumnCount(); i++) {
    stringBuilder.append(quirks.getColumnName(meta,i)).append("String_Node_Str");
  }
  return c.get(new Key(stringBuilder.toString(),this),meta);
}
Program: 14011
Project: 14011
Buggy source:
public PojoMetadata(Class clazz,boolean caseSensitive,boolean autoDeriveColumnNames,Map<String,String> columnMappings){
  this.caseSensitive=caseSensitive;
  this.autoDeriveColumnNames=autoDeriveColumnNames;
  this.clazz=clazz;
  this.columnMappings=columnMappings == null ? Collections.<String,String>emptyMap() : columnMappings;
  if (FeatureDetector.isCachePojoMetaDataEnabled()) {
    this.propertyInfo=getPropertyInfoThroughCache();
  }
 else {
    this.propertyInfo=initializePropertyInfo();
  }
}

Fixed version (ground truth):
public PojoMetadata(Class clazz,boolean caseSensitive,boolean autoDeriveColumnNames,Map<String,String> columnMappings){
  this.caseSensitive=caseSensitive;
  this.autoDeriveColumnNames=autoDeriveColumnNames;
  this.clazz=clazz;
  this.columnMappings=columnMappings == null ? Collections.<String,String>emptyMap() : columnMappings;
  this.propertyInfo=getPropertyInfoThroughCache();
}
Program: 14012
Project: 14012
Buggy source:
public Query bind(Object bean){
  Class clazz=bean.getClass();
  Method[] methods=clazz.getDeclaredMethods();
  for (  Method method : methods) {
    try {
      method.setAccessible(true);
      String methodName=method.getName();
      if (methodName.startsWith("String_Node_Str") && method.getParameterTypes().length == 0) {
        String param=methodName.substring(3);
        param=param.substring(0,1).toLowerCase() + param.substring(1);
        Object res=method.invoke(bean);
        this.addParameter(param,res);
      }
    }
 catch (    IllegalArgumentException ex) {
      logger.debug("String_Node_Str",ex);
    }
catch (    IllegalAccessException ex) {
      throw new RuntimeException(ex);
    }
catch (    InvocationTargetException ex) {
      throw new RuntimeException(ex);
    }
  }
  return this;
}

Fixed version (ground truth):
public Query bind(Object pojo){
  Class clazz=pojo.getClass();
  Map<String,PojoIntrospector.ReadableProperty> propertyMap=PojoIntrospector.readableProperties(clazz);
  for (  PojoIntrospector.ReadableProperty property : propertyMap.values()) {
    try {
      if (statement.containsParameter(property.name))       this.addParameter(property.name,property.get(pojo));
    }
 catch (    IllegalArgumentException ex) {
      logger.debug("String_Node_Str",ex);
    }
catch (    IllegalAccessException ex) {
      throw new RuntimeException(ex);
    }
catch (    InvocationTargetException ex) {
      throw new RuntimeException(ex);
    }
  }
  return this;
}
Program: 14013
Project: 14013
Buggy source:
@Test public void testBindPojo(){
  String createSql="String_Node_Str";
  sql2o.createQuery(createSql).executeUpdate();
  BindablePojo pojo1=new BindablePojo();
  pojo1.setData1("String_Node_Str");
  pojo1.setData2(new Timestamp(new Date().getTime()));
  pojo1.setData3(789456123L);
  pojo1.setData4(4.5f);
  String insertSql="String_Node_Str";
  sql2o.createQuery(insertSql).bind(pojo1).executeUpdate();
  String selectSql="String_Node_Str";
  BindablePojo pojo2=sql2o.createQuery(selectSql).executeAndFetchFirst(BindablePojo.class);
  assertTrue(pojo1.equals(pojo2));
}

Fixed version (ground truth):
@Test public void testBindPojo(){
  String createSql="String_Node_Str";
  sql2o.createQuery(createSql).executeUpdate();
  BindablePojo pojo1=new BindablePojo(){
{
      data1="String_Node_Str";
      setData2(new Timestamp(new Date().getTime()));
      setData3(789456123L);
      setData4(4.5f);
    }
  }
;
  String insertSql="String_Node_Str";
  sql2o.createQuery(insertSql).bind(pojo1).executeUpdate();
  String selectSql="String_Node_Str";
  BindablePojo pojo2=sql2o.createQuery(selectSql).executeAndFetchFirst(BindablePojo.class);
  assertTrue(pojo1.equals(pojo2));
}
Program: 14014
Project: 14014
Buggy source:
public static String convert(String underscore){
  if (underscore == null || underscore.trim().length() == 0)   return underscore;
  if (FeatureDetector.isCacheUnderscoreToCamelcaseEnabled() && cache.containsKey(underscore))   return cache.get(underscore);
  String[] stringTokens=underscore.split("String_Node_Str");
  StringBuilder camelCase=new StringBuilder();
  for (int i=0; i < stringTokens.length; i++) {
    if (i == 0) {
      camelCase.append(stringTokens[i].toLowerCase());
    }
 else {
      camelCase.append(Character.toUpperCase(stringTokens[i].charAt(0))).append(stringTokens[i].substring(1,stringTokens[i].length()).toLowerCase());
    }
  }
  String res=camelCase.toString();
  if (FeatureDetector.isCacheUnderscoreToCamelcaseEnabled())   cache.put(underscore,res);
  return res;
}

Fixed version (ground truth):
public static String convert(String underscore){
  if (underscore == null || underscore.isEmpty())   return underscore;
  return convert00(underscore);
}
Program: 14015
Project: 14015
Buggy source:
@Test public void testUUID(){
  Connection connection=null;
  try {
    connection=sql2o.beginTransaction();
    String createSql="String_Node_Str";
    connection.createQuery(createSql).executeUpdate();
    UUID uuid=UUID.randomUUID();
    String insertSql="String_Node_Str";
    connection.createQuery(insertSql).addParameter("String_Node_Str",uuid).executeUpdate();
    String selectSql="String_Node_Str";
    UUID fetchedUuid=connection.createQuery(selectSql).executeScalar(UUID.class);
    assertThat(fetchedUuid,is(equalTo(uuid)));
  }
  finally {
    if (connection != null) {
      connection.rollback();
    }
  }
}

Fixed version (ground truth):
@Test public void testUUID(){
  Convert.registerConverter(UUID.class,new UUIDConverter());
  Connection connection=null;
  try {
    connection=sql2o.beginTransaction();
    String createSql="String_Node_Str";
    connection.createQuery(createSql).executeUpdate();
    UUID uuid=UUID.randomUUID();
    String insertSql="String_Node_Str";
    connection.createQuery(insertSql).addParameter("String_Node_Str",uuid).executeUpdate();
    String selectSql="String_Node_Str";
    UUID fetchedUuid=connection.createQuery(selectSql).executeScalar(UUID.class);
    assertThat(fetchedUuid,is(equalTo(uuid)));
  }
  finally {
    if (connection != null) {
      connection.rollback();
    }
  }
}
Program: 14017
Project: 14017
Buggy source:
void setKeys(ResultSet rs) throws SQLException {
  if (rs == null) {
    return;
  }
  this.keys=new ArrayList<Object>();
  while (rs.next()) {
    this.keys.add(rs.getObject(1));
  }
}

Fixed version (ground truth):
void setKeys(ResultSet rs) throws SQLException {
  if (rs == null) {
    this.keys=null;
    return;
  }
  this.keys=new ArrayList<Object>();
  while (rs.next()) {
    this.keys.add(rs.getObject(1));
  }
}
Program: 14018
Project: 14018
Buggy source:
public Query(Connection connection,String queryText,String name,boolean returnGeneratedKeys){
  this.connection=connection;
  this.name=name;
  try {
    statement=new NamedParameterStatement(connection.getJdbcConnection(),queryText,returnGeneratedKeys);
  }
 catch (  Exception ex) {
    throw new RuntimeException(ex);
  }
  this.setColumnMappings(connection.getSql2o().getDefaultColumnMappings());
  this.caseSensitive=connection.getSql2o().isDefaultCaseSensitive();
  this.methodsMap=new HashMap<String,Method>();
}

Fixed version (ground truth):
public Query(Connection connection,String queryText,String name,boolean returnGeneratedKeys){
  this.connection=connection;
  this.name=name;
  this.returnGeneratedKeys=returnGeneratedKeys;
  try {
    statement=new NamedParameterStatement(connection.getJdbcConnection(),queryText,returnGeneratedKeys);
  }
 catch (  Exception ex) {
    throw new RuntimeException(ex);
  }
  this.setColumnMappings(connection.getSql2o().getDefaultColumnMappings());
  this.caseSensitive=connection.getSql2o().isDefaultCaseSensitive();
  this.methodsMap=new HashMap<String,Method>();
}
Program: 14019
Project: 14019
Buggy source:
public Connection executeUpdate(){
  long start=System.currentTimeMillis();
  try {
    this.connection.setResult(statement.executeUpdate());
    this.connection.setKeys(statement.getStatement().getGeneratedKeys());
    connection.setCanGetKeys(true);
  }
 catch (  SQLException ex) {
    this.connection.onException();
    throw new Sql2oException("String_Node_Str" + ex.getMessage(),ex);
  }
 finally {
    closeConnectionIfNecessary();
  }
  long end=System.currentTimeMillis();
  logger.info("String_Node_Str",new Object[]{end - start,this.getName() == null ? "String_Node_Str" : this.getName()});
  return this.connection;
}

Fixed version (ground truth):
public Connection executeUpdate(){
  long start=System.currentTimeMillis();
  try {
    this.connection.setResult(statement.executeUpdate());
    this.connection.setKeys(this.returnGeneratedKeys ? statement.getStatement().getGeneratedKeys() : null);
    connection.setCanGetKeys(true);
  }
 catch (  SQLException ex) {
    this.connection.onException();
    throw new Sql2oException("String_Node_Str" + ex.getMessage(),ex);
  }
 finally {
    closeConnectionIfNecessary();
  }
  long end=System.currentTimeMillis();
  logger.info("String_Node_Str",new Object[]{end - start,this.getName() == null ? "String_Node_Str" : this.getName()});
  return this.connection;
}
Program: 14020
Project: 14020
Buggy source:
public String convert(Object val){
  if (val == null) {
    return null;
  }
 else {
    return val.toString();
  }
}

Fixed version (ground truth):
public String convert(Object val) throws ConverterException {
  if (val == null) {
    return null;
  }
  if (val instanceof Clob) {
    Clob clobVal=(Clob)val;
    try {
      return clobVal.getSubString(1,(int)clobVal.length());
    }
 catch (    SQLException e) {
      throw new ConverterException("String_Node_Str",e);
    }
  }
  return val.toString();
}
Program: 14021
Project: 14021
Buggy source:
public <T>List<T> executeAndFetch(Class returnType){
  List list=new ArrayList();
  PojoMetadata metadata=new PojoMetadata(returnType,this.isCaseSensitive(),this.getColumnMappings());
  try {
    long start=System.currentTimeMillis();
    ResultSet rs=statement.executeQuery();
    long afterExecQuery=System.currentTimeMillis();
    ResultSetMetaData meta=rs.getMetaData();
    while (rs.next()) {
      Pojo pojo=new Pojo(metadata,this.isCaseSensitive());
      for (int colIdx=1; colIdx <= meta.getColumnCount(); colIdx++) {
        String colName=meta.getColumnLabel(colIdx);
        pojo.setProperty(colName,rs.getObject(colIdx));
      }
      list.add(pojo.getObject());
    }
    rs.close();
    long afterClose=System.currentTimeMillis();
    logger.info("String_Node_Str",new Object[]{afterClose - start,afterExecQuery - start,afterClose - afterExecQuery,this.getName() == null ? "String_Node_Str" : this.getName()});
  }
 catch (  SQLException ex) {
    throw new Sql2oException("String_Node_Str" + ex.getMessage(),ex);
  }
 finally {
    closeConnectionIfNecessary();
  }
  return list;
}

Fixed version (ground truth):
public <T>List<T> executeAndFetch(Class returnType){
  List list=new ArrayList();
  PojoMetadata metadata=new PojoMetadata(returnType,this.isCaseSensitive(),this.getColumnMappings());
  try {
    long start=System.currentTimeMillis();
    ResultSet rs=statement.executeQuery();
    long afterExecQuery=System.currentTimeMillis();
    ResultSetMetaData meta=rs.getMetaData();
    while (rs.next()) {
      Pojo pojo=new Pojo(metadata,this.isCaseSensitive());
      for (int colIdx=1; colIdx <= meta.getColumnCount(); colIdx++) {
        String colName;
        if (this.connection.getSql2o().quirksMode == QuirksMode.DB2) {
          colName=meta.getColumnName(colIdx);
        }
 else {
          colName=meta.getColumnLabel(colIdx);
        }
        pojo.setProperty(colName,rs.getObject(colIdx));
      }
      list.add(pojo.getObject());
    }
    rs.close();
    long afterClose=System.currentTimeMillis();
    logger.info("String_Node_Str",new Object[]{afterClose - start,afterExecQuery - start,afterClose - afterExecQuery,this.getName() == null ? "String_Node_Str" : this.getName()});
  }
 catch (  SQLException ex) {
    throw new Sql2oException("String_Node_Str" + ex.getMessage(),ex);
  }
 finally {
    closeConnectionIfNecessary();
  }
  return list;
}
Program: 14022
Project: 14022
Buggy source:
public Table executeAndFetchTable(){
  ResultSet rs;
  long start=System.currentTimeMillis();
  try {
    rs=statement.executeQuery();
    long afterExecute=System.currentTimeMillis();
    Table table=TableFactory.createTable(rs,this.isCaseSensitive());
    long afterClose=System.currentTimeMillis();
    logger.info("String_Node_Str",new Object[]{afterClose - start,afterExecute - start,afterClose - afterExecute,this.getName() == null ? "String_Node_Str" : this.getName()});
    return table;
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
 finally {
    closeConnectionIfNecessary();
  }
}

Fixed version (ground truth):
public Table executeAndFetchTable(){
  ResultSet rs;
  long start=System.currentTimeMillis();
  try {
    rs=statement.executeQuery();
    long afterExecute=System.currentTimeMillis();
    Table table=TableFactory.createTable(rs,this.isCaseSensitive(),this.connection.getSql2o().quirksMode);
    long afterClose=System.currentTimeMillis();
    logger.info("String_Node_Str",new Object[]{afterClose - start,afterExecute - start,afterClose - afterExecute,this.getName() == null ? "String_Node_Str" : this.getName()});
    return table;
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
 finally {
    closeConnectionIfNecessary();
  }
}
Program: 14023
Project: 14023
Buggy source:
public static Table createTable(ResultSet rs,boolean isCaseSensitive){
  Table table=new Table(isCaseSensitive);
  try {
    applyMetadata(table,rs.getMetaData());
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
  try {
    while (rs.next()) {
      Row row=new Row(table);
      table.rows().add(row);
      for (      Column column : table.columns()) {
        row.addValue(column.getIndex(),rs.getObject(column.getIndex() + 1));
      }
    }
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
  return table;
}

Fixed version (ground truth):
public static Table createTable(ResultSet rs,boolean isCaseSensitive,QuirksMode quirksMode){
  Table table=new Table(isCaseSensitive);
  try {
    applyMetadata(table,rs.getMetaData(),quirksMode);
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
  try {
    while (rs.next()) {
      Row row=new Row(table);
      table.rows().add(row);
      for (      Column column : table.columns()) {
        row.addValue(column.getIndex(),rs.getObject(column.getIndex() + 1));
      }
    }
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
  return table;
}
Program: 14024
Project: 14024
Buggy source:
private static void applyMetadata(Table table,ResultSetMetaData metadata) throws SQLException {
  table.setName(metadata.getTableName(1));
  for (int colIdx=1; colIdx <= metadata.getColumnCount(); colIdx++) {
    String colName=metadata.getColumnLabel(colIdx);
    String colType=metadata.getColumnTypeName(colIdx);
    table.columns().add(new Column(colName,colIdx - 1,colType));
    String colMapName=table.isCaseSensitive() ? colName : colName.toLowerCase();
    table.getColumnNameToIdxMap().put(colMapName,colIdx - 1);
  }
}

Fixed version (ground truth):
private static void applyMetadata(Table table,ResultSetMetaData metadata,QuirksMode quirksMode) throws SQLException {
  table.setName(metadata.getTableName(1));
  for (int colIdx=1; colIdx <= metadata.getColumnCount(); colIdx++) {
    String colName;
    if (quirksMode == QuirksMode.DB2) {
      colName=metadata.getColumnName(colIdx);
    }
 else {
      colName=metadata.getColumnLabel(colIdx);
    }
    String colType=metadata.getColumnTypeName(colIdx);
    table.columns().add(new Column(colName,colIdx - 1,colType));
    String colMapName=table.isCaseSensitive() ? colName : colName.toLowerCase();
    table.getColumnNameToIdxMap().put(colMapName,colIdx - 1);
  }
}
Program: 14025
Project: 14025
Buggy source:
public Enum convert(Object val) throws ConverterException {
  try {
    if (String.class.isAssignableFrom(val.getClass())) {
      return Enum.valueOf(enumType,val.toString());
    }
 else     if (Number.class.isAssignableFrom(val.getClass())) {
      return (Enum)enumType.getEnumConstants()[((Number)val).intValue()];
    }
  }
 catch (  Throwable t) {
    throw new ConverterException("String_Node_Str" + val.toString() + "String_Node_Str"+ enumType.getName(),t);
  }
  throw new ConverterException("String_Node_Str" + val.getClass().getName() + "String_Node_Str");
}

Fixed version (ground truth):
public Enum convert(Object val) throws ConverterException {
  if (val == null)   return null;
  try {
    if (String.class.isAssignableFrom(val.getClass())) {
      return Enum.valueOf(enumType,val.toString());
    }
 else     if (Number.class.isAssignableFrom(val.getClass())) {
      return (Enum)enumType.getEnumConstants()[((Number)val).intValue()];
    }
  }
 catch (  Throwable t) {
    throw new ConverterException("String_Node_Str" + val.toString() + "String_Node_Str"+ enumType.getName(),t);
  }
  throw new ConverterException("String_Node_Str" + val.getClass().getName() + "String_Node_Str");
}
Program: 14026
Project: 14026
Buggy source:
@Test public void testEnums(){
  sql2o.createQuery("String_Node_Str").executeUpdate();
  sql2o.createQuery("String_Node_Str").addParameter("String_Node_Str",TestEnum.HELLO).addParameter("String_Node_Str",TestEnum.HELLO.ordinal()).addToBatch().addParameter("String_Node_Str",TestEnum.WORLD).addParameter("String_Node_Str",TestEnum.WORLD.ordinal()).addToBatch().executeBatch();
  List<EntityWithEnum> list=sql2o.createQuery("String_Node_Str").executeAndFetch(EntityWithEnum.class);
  assertThat(list.get(0).val,is(TestEnum.HELLO));
  assertThat(list.get(0).val2,is(TestEnum.HELLO));
  assertThat(list.get(1).val,is(TestEnum.WORLD));
  assertThat(list.get(1).val2,is(TestEnum.WORLD));
  TestEnum testEnum=sql2o.createQuery("String_Node_Str").executeScalar(TestEnum.class);
  assertThat(testEnum,is(TestEnum.HELLO));
}

Fixed version (ground truth):
@Test public void testEnums(){
  sql2o.createQuery("String_Node_Str").executeUpdate();
  sql2o.createQuery("String_Node_Str").addParameter("String_Node_Str",TestEnum.HELLO).addParameter("String_Node_Str",TestEnum.HELLO.ordinal()).addToBatch().addParameter("String_Node_Str",TestEnum.WORLD).addParameter("String_Node_Str",TestEnum.WORLD.ordinal()).addToBatch().executeBatch();
  List<EntityWithEnum> list=sql2o.createQuery("String_Node_Str").executeAndFetch(EntityWithEnum.class);
  assertThat(list.get(0).val,is(TestEnum.HELLO));
  assertThat(list.get(0).val2,is(TestEnum.HELLO));
  assertThat(list.get(1).val,is(TestEnum.WORLD));
  assertThat(list.get(1).val2,is(TestEnum.WORLD));
  TestEnum testEnum=sql2o.createQuery("String_Node_Str").executeScalar(TestEnum.class);
  assertThat(testEnum,is(TestEnum.HELLO));
  TestEnum testEnum2=sql2o.createQuery("String_Node_Str").executeScalar(TestEnum.class);
  assertThat(testEnum2,is(nullValue()));
}
Program: 14027
Project: 14027
Buggy source:
public <T>List<T> executeAndFetch(Class returnType){
  List list=new ArrayList();
  PojoMetadata metadata=new PojoMetadata(returnType,this.isCaseSensitive(),this.getColumnMappings());
  try {
    long start=System.currentTimeMillis();
    ResultSet rs=statement.executeQuery();
    long afterExecQuery=System.currentTimeMillis();
    ResultSetMetaData meta=rs.getMetaData();
    while (rs.next()) {
      Pojo pojo=new Pojo(metadata,this.isCaseSensitive());
      for (int colIdx=1; colIdx <= meta.getColumnCount(); colIdx++) {
        String colName=meta.getColumnLabel(colIdx);
        pojo.setProperty(colName,rs.getObject(colIdx));
      }
      list.add(pojo.getObject());
    }
    rs.close();
    long afterClose=System.currentTimeMillis();
    logger.info("String_Node_Str",new Object[]{afterClose - start,afterExecQuery - start,afterClose - afterExecQuery,this.getName() == null ? "String_Node_Str" : this.getName()});
  }
 catch (  SQLException ex) {
    throw new Sql2oException("String_Node_Str" + ex.getMessage(),ex);
  }
 finally {
    closeConnectionIfNecessary();
  }
  return list;
}

Fixed version (ground truth):
public <T>List<T> executeAndFetch(Class returnType){
  List list=new ArrayList();
  PojoMetadata metadata=new PojoMetadata(returnType,this.isCaseSensitive(),this.getColumnMappings());
  try {
    long start=System.currentTimeMillis();
    ResultSet rs=statement.executeQuery();
    long afterExecQuery=System.currentTimeMillis();
    ResultSetMetaData meta=rs.getMetaData();
    while (rs.next()) {
      Pojo pojo=new Pojo(metadata,this.isCaseSensitive());
      for (int colIdx=1; colIdx <= meta.getColumnCount(); colIdx++) {
        String colName;
        if (this.connection.getSql2o().quirksMode == QuirksMode.DB2) {
          colName=meta.getColumnName(colIdx);
        }
 else {
          colName=meta.getColumnLabel(colIdx);
        }
        pojo.setProperty(colName,rs.getObject(colIdx));
      }
      list.add(pojo.getObject());
    }
    rs.close();
    long afterClose=System.currentTimeMillis();
    logger.info("String_Node_Str",new Object[]{afterClose - start,afterExecQuery - start,afterClose - afterExecQuery,this.getName() == null ? "String_Node_Str" : this.getName()});
  }
 catch (  SQLException ex) {
    throw new Sql2oException("String_Node_Str" + ex.getMessage(),ex);
  }
 finally {
    closeConnectionIfNecessary();
  }
  return list;
}
Program: 14028
Project: 14028
Buggy source:
public Table executeAndFetchTable(){
  ResultSet rs;
  long start=System.currentTimeMillis();
  try {
    rs=statement.executeQuery();
    long afterExecute=System.currentTimeMillis();
    Table table=TableFactory.createTable(rs,this.isCaseSensitive());
    long afterClose=System.currentTimeMillis();
    logger.info("String_Node_Str",new Object[]{afterClose - start,afterExecute - start,afterClose - afterExecute,this.getName() == null ? "String_Node_Str" : this.getName()});
    return table;
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
 finally {
    closeConnectionIfNecessary();
  }
}

Fixed version (ground truth):
public Table executeAndFetchTable(){
  ResultSet rs;
  long start=System.currentTimeMillis();
  try {
    rs=statement.executeQuery();
    long afterExecute=System.currentTimeMillis();
    Table table=TableFactory.createTable(rs,this.isCaseSensitive(),this.connection.getSql2o().quirksMode);
    long afterClose=System.currentTimeMillis();
    logger.info("String_Node_Str",new Object[]{afterClose - start,afterExecute - start,afterClose - afterExecute,this.getName() == null ? "String_Node_Str" : this.getName()});
    return table;
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
 finally {
    closeConnectionIfNecessary();
  }
}
Program: 14029
Project: 14029
Buggy source:
public static Table createTable(ResultSet rs,boolean isCaseSensitive){
  Table table=new Table(isCaseSensitive);
  try {
    applyMetadata(table,rs.getMetaData());
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
  try {
    while (rs.next()) {
      Row row=new Row(table);
      table.rows().add(row);
      for (      Column column : table.columns()) {
        row.addValue(column.getIndex(),rs.getObject(column.getIndex() + 1));
      }
    }
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
  return table;
}

Fixed version (ground truth):
public static Table createTable(ResultSet rs,boolean isCaseSensitive,QuirksMode quirksMode){
  Table table=new Table(isCaseSensitive);
  try {
    applyMetadata(table,rs.getMetaData(),quirksMode);
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
  try {
    while (rs.next()) {
      Row row=new Row(table);
      table.rows().add(row);
      for (      Column column : table.columns()) {
        row.addValue(column.getIndex(),rs.getObject(column.getIndex() + 1));
      }
    }
  }
 catch (  SQLException e) {
    throw new Sql2oException("String_Node_Str",e);
  }
  return table;
}
Program: 14030
Project: 14030
Buggy source:
private static void applyMetadata(Table table,ResultSetMetaData metadata) throws SQLException {
  table.setName(metadata.getTableName(1));
  for (int colIdx=1; colIdx <= metadata.getColumnCount(); colIdx++) {
    String colName=metadata.getColumnLabel(colIdx);
    String colType=metadata.getColumnTypeName(colIdx);
    table.columns().add(new Column(colName,colIdx - 1,colType));
    String colMapName=table.isCaseSensitive() ? colName : colName.toLowerCase();
    table.getColumnNameToIdxMap().put(colMapName,colIdx - 1);
  }
}

Fixed version (ground truth):
private static void applyMetadata(Table table,ResultSetMetaData metadata,QuirksMode quirksMode) throws SQLException {
  table.setName(metadata.getTableName(1));
  for (int colIdx=1; colIdx <= metadata.getColumnCount(); colIdx++) {
    String colName;
    if (quirksMode == QuirksMode.DB2) {
      colName=metadata.getColumnName(colIdx);
    }
 else {
      colName=metadata.getColumnLabel(colIdx);
    }
    String colType=metadata.getColumnTypeName(colIdx);
    table.columns().add(new Column(colName,colIdx - 1,colType));
    String colMapName=table.isCaseSensitive() ? colName : colName.toLowerCase();
    table.getColumnNameToIdxMap().put(colMapName,colIdx - 1);
  }
}