Program: 138634
Project: 138634
Buggy source:
/** 
 * zshen get driver by metadataConnection information.
 * @param metadataConnection contain the information which about driver.
 * @return if can't find the driver will get a null.
 */
public Driver getDriver(IMetadataConnection metadataConnection) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  Driver driver=null;
  String driverClassName=metadataConnection.getDriverClass();
  SQLExplorerPlugin sqlExplorerPlugin=SQLExplorerPlugin.getDefault();
  if (sqlExplorerPlugin != null) {
    net.sourceforge.sqlexplorer.dbproduct.DriverManager driverModel=sqlExplorerPlugin.getDriverModel();
    try {
      Collection<ManagedDriver> drivers=driverModel.getDrivers();
      for (      ManagedDriver managedDriver : drivers) {
        LinkedList<String> jars=managedDriver.getJars();
        List<URL> urls=new ArrayList<URL>();
        for (int i=0; i < jars.size(); i++) {
          File file=new File(jars.get(i));
          if (file.exists()) {
            urls.add(file.toURI().toURL());
          }
        }
        if (!urls.isEmpty()) {
          try {
            MyURLClassLoader cl;
            cl=new MyURLClassLoader(urls.toArray(new URL[0]));
            Class<?> clazz=cl.findClass(driverClassName);
            if (clazz != null) {
              driver=(Driver)clazz.newInstance();
            }
          }
 catch (          ClassNotFoundException e) {
          }
        }
      }
    }
 catch (    MalformedURLException e) {
    }
  }
  if (driver == null) {
    driver=(Driver)Class.forName(driverClassName).newInstance();
  }
  return driver;
}

Fixed version (ground truth):
/** 
 * zshen get driver by metadataConnection information.
 * @param metadataConnection contain the information which about driver.
 * @return if can't find the driver will get a null.
 */
public Driver getDriver(IMetadataConnection metadataConnection) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  Driver driver=null;
  String driverClassName=metadataConnection.getDriverClass();
  String jarsPath=metadataConnection.getDriverJarPath();
  if (StringUtils.isNotEmpty(jarsPath)) {
    try {
      driver=this.createGenericJDBC(jarsPath,driverClassName);
    }
 catch (    Exception e) {
      log.error(e,e);
    }
    return driver;
  }
  SQLExplorerPlugin sqlExplorerPlugin=SQLExplorerPlugin.getDefault();
  if (sqlExplorerPlugin != null) {
    net.sourceforge.sqlexplorer.dbproduct.DriverManager driverModel=sqlExplorerPlugin.getDriverModel();
    try {
      Collection<ManagedDriver> drivers=driverModel.getDrivers();
      for (      ManagedDriver managedDriver : drivers) {
        LinkedList<String> jars=managedDriver.getJars();
        List<URL> urls=new ArrayList<URL>();
        for (int i=0; i < jars.size(); i++) {
          File file=new File(jars.get(i));
          if (file.exists()) {
            urls.add(file.toURI().toURL());
          }
        }
        if (!urls.isEmpty()) {
          try {
            MyURLClassLoader cl;
            cl=new MyURLClassLoader(urls.toArray(new URL[0]));
            Class<?> clazz=cl.findClass(driverClassName);
            if (clazz != null) {
              driver=(Driver)clazz.newInstance();
              if (driver != null) {
                return driver;
              }
            }
          }
 catch (          ClassNotFoundException e) {
          }
        }
      }
    }
 catch (    MalformedURLException e) {
    }
  }
  if (driver == null) {
    driver=(Driver)Class.forName(driverClassName).newInstance();
  }
  return driver;
}