Program: 29429
Project: 29429
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.DataSource dataSource=getDataSource();
  java.sql.Connection dsConn=null;
  com.sun.gjc.spi.ManagedConnection mc=null;
  try {
    if (isEqual(pc,getUser(),getPassword())) {
      dsConn=dataSource.getConnection();
    }
 else {
      dsConn=dataSource.getConnection(pc.getUserName(),new String(pc.getPassword()));
    }
  }
 catch (  java.sql.SQLException sqle) {
    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE,"String_Node_Str",sqle.getMessage());
    }
    StringManager localStrings=StringManager.getManager(DataSourceObjectBuilder.class);
    String msg=localStrings.getString("String_Node_Str",sqle.getMessage());
    ResourceAllocationException rae=new ResourceAllocationException(msg);
    rae.initCause(sqle);
    throw rae;
  }
  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" + "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
 * @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.DataSource dataSource=getDataSource();
  java.sql.Connection dsConn=null;
  ManagedConnectionImpl mc=null;
  try {
    if (isEqual(pc,getUser(),getPassword())) {
      dsConn=dataSource.getConnection();
    }
 else {
      dsConn=dataSource.getConnection(pc.getUserName(),new String(pc.getPassword()));
    }
  }
 catch (  java.sql.SQLException sqle) {
    if (_logger.isLoggable(Level.FINE)) {
      _logger.log(Level.FINE,"String_Node_Str",sqle.getMessage());
    }
    StringManager localStrings=StringManager.getManager(DataSourceObjectBuilder.class);
    String msg=localStrings.getString("String_Node_Str",sqle.getMessage());
    ResourceAllocationException rae=new ResourceAllocationException(msg);
    rae.initCause(sqle);
    throw rae;
  }
  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" + "String_Node_Str" + dsConn);
        }
      }
    }
  }
  return mc;
}