Program: 29427
Project: 29427
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
 * @throws ResourceAllocationException if there is an error in allocating thephysical connection
 */
public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,ConnectionRequestInfo cxRequestInfo) throws ResourceException {
  logFine("String_Node_Str");
  PasswordCredential pc=SecurityUtils.getPasswordCredential(this,subject,cxRequestInfo);
  javax.sql.ConnectionPoolDataSource dataSource=getDataSource();
  javax.sql.PooledConnection cpConn=null;
  com.sun.gjc.spi.ManagedConnection mc=null;
  try {
    if (isEqual(pc,getUser(),getPassword())) {
      cpConn=dataSource.getPooledConnection();
    }
 else {
      cpConn=dataSource.getPooledConnection(pc.getUserName(),new String(pc.getPassword()));
    }
  }
 catch (  java.sql.SQLException sqle) {
    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE,"String_Node_Str",sqle);
    }
    StringManager sm=StringManager.getManager(DataSourceObjectBuilder.class);
    String msg=sm.getString("String_Node_Str",sqle.getMessage());
    ResourceAllocationException rae=new ResourceAllocationException(msg,sqle);
    throw rae;
  }
  try {
    mc=constructManagedConnection(cpConn,null,pc,this);
    mc.initializeConnectionType(ManagedConnection.ISPOOLEDCONNECTION);
    validateAndSetIsolation(mc);
  }
  finally {
    if (mc == null) {
      if (cpConn != null) {
        try {
          cpConn.close();
        }
 catch (        SQLException e) {
          _logger.log(Level.FINEST,"String_Node_Str" + cpConn);
        }
      }
    }
  }
  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
 * @throws ResourceAllocationException if there is an error in allocating thephysical connection
 */
public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject,ConnectionRequestInfo cxRequestInfo) throws ResourceException {
  logFine("String_Node_Str");
  PasswordCredential pc=SecurityUtils.getPasswordCredential(this,subject,cxRequestInfo);
  javax.sql.ConnectionPoolDataSource dataSource=getDataSource();
  javax.sql.PooledConnection cpConn=null;
  ManagedConnectionImpl mc=null;
  try {
    if (isEqual(pc,getUser(),getPassword())) {
      cpConn=dataSource.getPooledConnection();
    }
 else {
      cpConn=dataSource.getPooledConnection(pc.getUserName(),new String(pc.getPassword()));
    }
  }
 catch (  java.sql.SQLException sqle) {
    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE,"String_Node_Str",sqle);
    }
    StringManager sm=StringManager.getManager(DataSourceObjectBuilder.class);
    String msg=sm.getString("String_Node_Str",sqle.getMessage());
    ResourceAllocationException rae=new ResourceAllocationException(msg,sqle);
    throw rae;
  }
  try {
    mc=constructManagedConnection(cpConn,null,pc,this);
    mc.initializeConnectionType(ManagedConnectionImpl.ISPOOLEDCONNECTION);
    validateAndSetIsolation(mc);
  }
  finally {
    if (mc == null) {
      if (cpConn != null) {
        try {
          cpConn.close();
        }
 catch (        SQLException e) {
          _logger.log(Level.FINEST,"String_Node_Str" + cpConn);
        }
      }
    }
  }
  return mc;
}