Program: 29428
Project: 29428
Buggy source:
/** 
 * Creates a new physical connection to the underlying EIS resource manager.
 * @param subject       <code>Subject</code> instance passed by the application server
 * @param cxRequestInfo <code>ConnectionRequestInfo</code> which may be createdas a result of the invocation <code>getConnection(user, password)</code> on the <code>DataSource</code> object
 * @return <code>ManagedConnection</code> object created
 * @throws ResourceException if there is an error in instantiating the<code>DataSource</code> object used for the creation of the <code>ManagedConnection</code> object
 * @throws SecurityException if there ino <code>PasswordCredential</code> objectsatisfying this request
 */
public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,ConnectionRequestInfo cxRequestInfo) throws ResourceException {
  logFine("String_Node_Str");
  if (dsObjBuilder == null) {
    dsObjBuilder=new DataSourceObjectBuilder(spec);
  }
  PasswordCredential pc=SecurityUtils.getPasswordCredential(this,subject,cxRequestInfo);
  try {
    Class.forName(spec.getDetail(DataSourceSpec.CLASSNAME));
  }
 catch (  ClassNotFoundException cnfe) {
    _logger.log(Level.SEVERE,"String_Node_Str",cnfe);
    throw new ResourceException("String_Node_Str" + spec.getDetail(DataSourceSpec.CLASSNAME));
  }
  java.sql.Connection dsConn=null;
  com.sun.gjc.spi.ManagedConnection mc=null;
  Properties driverProps=new Properties();
  Hashtable properties=dsObjBuilder.parseDriverProperties(spec,false);
  Set<Map.Entry<String,Vector>> entries=(Set<Map.Entry<String,Vector>>)properties.entrySet();
  for (  Map.Entry<String,Vector> entry : entries) {
    String value="String_Node_Str";
    String key=(String)entry.getKey();
    Vector values=(Vector)entry.getValue();
    if (!values.isEmpty() && values.size() == 1) {
      value=(String)values.firstElement();
    }
 else     if (values.size() > 1) {
      logFine("String_Node_Str" + key);
    }
    String prop=getParsedKey(key);
    driverProps.put(prop,value);
    if (prop.equalsIgnoreCase("String_Node_Str")) {
      if (spec.getDetail(DataSourceSpec.URL) == null) {
        setConnectionURL(value);
      }
    }
  }
  try {
    if (cxRequestInfo != null) {
      driverProps.setProperty("String_Node_Str",pc.getUserName());
      driverProps.setProperty("String_Node_Str",new String(pc.getPassword()));
    }
 else {
      String user=spec.getDetail(DataSourceSpec.USERNAME);
      String password=spec.getDetail(DataSourceSpec.PASSWORD);
      if (user != null) {
        driverProps.setProperty("String_Node_Str",user);
      }
      if (password != null) {
        driverProps.setProperty("String_Node_Str",password);
      }
    }
    dsConn=DriverManager.getConnection(spec.getDetail(DataSourceSpec.URL),driverProps);
  }
 catch (  java.sql.SQLException sqle) {
    _logger.log(Level.SEVERE,"String_Node_Str",sqle);
    throw new javax.resource.spi.ResourceAllocationException("String_Node_Str" + sqle.getMessage());
  }
  try {
    mc=constructManagedConnection(null,dsConn,pc,this);
    validateAndSetIsolation(mc);
  }
  finally {
    if (mc == null) {
      if (dsConn != null) {
        try {
          dsConn.close();
        }
 catch (        SQLException e) {
          _logger.log(Level.FINEST,"String_Node_Str" + dsConn);
        }
      }
    }
  }
  return mc;
}

Fixed version (ground truth):
/** 
 * Creates a new physical connection to the underlying EIS resource manager.
 * @param subject       <code>Subject</code> instance passed by the application server
 * @param cxRequestInfo <code>ConnectionRequestInfo</code> which may be createdas a result of the invocation <code>getConnection(user, password)</code> on the <code>DataSource</code> object
 * @return <code>ManagedConnection</code> object created
 * @throws ResourceException if there is an error in instantiating the<code>DataSource</code> object used for the creation of the <code>ManagedConnection</code> object
 * @throws SecurityException if there ino <code>PasswordCredential</code> objectsatisfying this request
 */
public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,ConnectionRequestInfo cxRequestInfo) throws ResourceException {
  logFine("String_Node_Str");
  if (dsObjBuilder == null) {
    dsObjBuilder=new DataSourceObjectBuilder(spec);
  }
  PasswordCredential pc=SecurityUtils.getPasswordCredential(this,subject,cxRequestInfo);
  try {
    Class.forName(spec.getDetail(DataSourceSpec.CLASSNAME));
  }
 catch (  ClassNotFoundException cnfe) {
    _logger.log(Level.SEVERE,"String_Node_Str",cnfe);
    throw new ResourceException("String_Node_Str" + spec.getDetail(DataSourceSpec.CLASSNAME));
  }
  java.sql.Connection dsConn=null;
  ManagedConnectionImpl mc=null;
  Properties driverProps=new Properties();
  Hashtable properties=dsObjBuilder.parseDriverProperties(spec,false);
  Set<Map.Entry<String,Vector>> entries=(Set<Map.Entry<String,Vector>>)properties.entrySet();
  for (  Map.Entry<String,Vector> entry : entries) {
    String value="String_Node_Str";
    String key=(String)entry.getKey();
    Vector values=(Vector)entry.getValue();
    if (!values.isEmpty() && values.size() == 1) {
      value=(String)values.firstElement();
    }
 else     if (values.size() > 1) {
      logFine("String_Node_Str" + key);
    }
    String prop=getParsedKey(key);
    driverProps.put(prop,value);
    if (prop.equalsIgnoreCase("String_Node_Str")) {
      if (spec.getDetail(DataSourceSpec.URL) == null) {
        setConnectionURL(value);
      }
    }
  }
  try {
    if (cxRequestInfo != null) {
      driverProps.setProperty("String_Node_Str",pc.getUserName());
      driverProps.setProperty("String_Node_Str",new String(pc.getPassword()));
    }
 else {
      String user=spec.getDetail(DataSourceSpec.USERNAME);
      String password=spec.getDetail(DataSourceSpec.PASSWORD);
      if (user != null) {
        driverProps.setProperty("String_Node_Str",user);
      }
      if (password != null) {
        driverProps.setProperty("String_Node_Str",password);
      }
    }
    dsConn=DriverManager.getConnection(spec.getDetail(DataSourceSpec.URL),driverProps);
  }
 catch (  java.sql.SQLException sqle) {
    _logger.log(Level.SEVERE,"String_Node_Str",sqle);
    throw new javax.resource.spi.ResourceAllocationException("String_Node_Str" + sqle.getMessage());
  }
  try {
    mc=constructManagedConnection(null,dsConn,pc,this);
    validateAndSetIsolation(mc);
  }
  finally {
    if (mc == null) {
      if (dsConn != null) {
        try {
          dsConn.close();
        }
 catch (        SQLException e) {
          _logger.log(Level.FINEST,"String_Node_Str" + dsConn);
        }
      }
    }
  }
  return mc;
}