Program: 34518
Project: 34518
Buggy source:
/** 
 * Load java.sql.Driver implementations available to the specific class loader and return the first that accepts the URL (if any) that is specified in the vendor properties.
 * @param vProps configured JDBC vendor properties.
 * @param classloader class loader from which to load JDBC drivers.
 * @return Driver instance that accepts the URL. NULL if no such Driver can be loaded.
 * @throws SQLException if an error occurs.
 */
private Driver loadDriver(Properties vProps,ClassLoader classloader) throws SQLException {
  String url=vProps.getProperty("String_Node_Str",vProps.getProperty("String_Node_Str"));
  final boolean trace=TraceComponent.isAnyTracingEnabled();
  if (trace && tc.isDebugEnabled())   Tr.entry(this,tc,"String_Node_Str",url,classloader);
  SQLException failure=null;
  if (url != null)   for (  Driver driver : ServiceLoader.load(Driver.class,classloader)) {
    boolean acceptsURL;
    try {
      acceptsURL=driver.acceptsURL(url);
    }
 catch (    SQLException x) {
      if (failure != null)       failure=x;
      acceptsURL=false;
    }
    if (acceptsURL) {
      for (      Map.Entry<Object,Object> prop : vProps.entrySet()) {
        Object value=prop.getValue();
        if (value instanceof String) {
          String str=(String)value;
          if (PropertyService.isPassword((String)prop.getKey()) && PasswordUtil.getCryptoAlgorithm(str) != null)           try {
            prop.setValue(PasswordUtil.decode(str));
          }
 catch (          Exception x) {
            if (trace && tc.isEntryEnabled())             Tr.exit(this,tc,"String_Node_Str",x);
            if (x instanceof SQLException)             throw (SQLException)x;
 else             throw new SQLNonTransientException(x);
          }
        }
 else {
          prop.setValue(value.toString());
        }
      }
      if (classloader != null && url.startsWith("String_Node_Str") && isDerbyEmbedded.compareAndSet(false,true)) {
        embDerbyRefCount.add(classloader);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())         Tr.debug(this,tc,"String_Node_Str",classloader,embDerbyRefCount);
      }
      if (trace && tc.isEntryEnabled())       Tr.exit(this,tc,"String_Node_Str",driver);
      return driver;
    }
 else {
      if (trace && tc.isDebugEnabled())       Tr.debug(this,tc,driver + "String_Node_Str");
    }
  }
  if (trace && tc.isEntryEnabled())   Tr.exit(this,tc,"String_Node_Str",failure);
  if (failure == null)   return null;
 else   throw failure;
}

Fixed version (ground truth):
/** 
 * Load java.sql.Driver implementations available to the specific class loader and return the first that accepts the URL (if any) that is specified in the vendor properties.
 * @param vProps configured JDBC vendor properties.
 * @param classloader class loader from which to load JDBC drivers.
 * @return Driver instance that accepts the URL. NULL if no such Driver can be loaded.
 * @throws SQLException if an error occurs.
 */
private Driver loadDriver(Properties vProps,ClassLoader classloader) throws SQLException {
  String url=vProps.getProperty("String_Node_Str",vProps.getProperty("String_Node_Str"));
  final boolean trace=TraceComponent.isAnyTracingEnabled();
  if (trace && tc.isDebugEnabled())   Tr.entry(this,tc,"String_Node_Str",url,classloader);
  SQLException failure=null;
  if (url != null)   for (  Driver driver : ServiceLoader.load(Driver.class,classloader)) {
    boolean acceptsURL;
    try {
      acceptsURL=driver.acceptsURL(url);
    }
 catch (    SQLException x) {
      if (failure == null)       failure=x;
      acceptsURL=false;
    }
    if (acceptsURL) {
      for (      Map.Entry<Object,Object> prop : vProps.entrySet()) {
        Object value=prop.getValue();
        if (value instanceof String) {
          String str=(String)value;
          if (PropertyService.isPassword((String)prop.getKey()) && PasswordUtil.getCryptoAlgorithm(str) != null)           try {
            prop.setValue(PasswordUtil.decode(str));
          }
 catch (          Exception x) {
            if (trace && tc.isEntryEnabled())             Tr.exit(this,tc,"String_Node_Str",x);
            if (x instanceof SQLException)             throw (SQLException)x;
 else             throw new SQLNonTransientException(x);
          }
        }
 else {
          prop.setValue(value.toString());
        }
      }
      if (classloader != null && url.startsWith("String_Node_Str") && isDerbyEmbedded.compareAndSet(false,true)) {
        embDerbyRefCount.add(classloader);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())         Tr.debug(this,tc,"String_Node_Str",classloader,embDerbyRefCount);
      }
      if (trace && tc.isEntryEnabled())       Tr.exit(this,tc,"String_Node_Str",driver);
      return driver;
    }
 else {
      if (trace && tc.isDebugEnabled())       Tr.debug(this,tc,driver + "String_Node_Str");
    }
  }
  if (trace && tc.isEntryEnabled())   Tr.exit(this,tc,"String_Node_Str",failure);
  if (failure == null)   return null;
 else   throw failure;
}