Program: 137027
Project: 137027
Buggy source:
public static TypedReturnCode<Connection> getRefreshedDataProvider(Connection prevDataProvider){
  TypedReturnCode<Connection> returnProvider=new TypedReturnCode<Connection>();
  boolean mdm=ConnectionUtils.isMdmConnection(prevDataProvider);
  IMetadataConnection metadataConnection=ConvertionHelper.convert((DatabaseConnection)prevDataProvider,false,prevDataProvider.getContextName());
  Connection copyedConnection=null;
  if (mdm) {
    copyedConnection=MetadataFillFactory.getMDMInstance().fillUIConnParams(metadataConnection,null);
    MetadataFillFactory.getMDMInstance().fillSchemas(copyedConnection,null,null);
  }
 else {
    EDatabaseTypeName currentEDatabaseType=EDatabaseTypeName.getTypeFromDbType(metadataConnection.getDbType());
    if (currentEDatabaseType != null) {
      MetadataFillFactory dbInstance=MetadataFillFactory.getDBInstance(currentEDatabaseType);
      TypedReturnCode<?> trc=(TypedReturnCode<?>)dbInstance.createConnection(metadataConnection);
      Object sqlConnObject=trc.getObject();
      DatabaseMetaData dbJDBCMetadata=null;
      if (trc.isOk() && sqlConnObject instanceof java.sql.Connection) {
        java.sql.Connection sqlConn=(java.sql.Connection)sqlConnObject;
        dbJDBCMetadata=ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConn,(DatabaseConnection)prevDataProvider);
        copyedConnection=EObjectHelper.deepCopy(prevDataProvider);
        copyedConnection.getDataPackage().clear();
        MetadataFillFactory.getDBInstance(currentEDatabaseType).fillCatalogs(copyedConnection,dbJDBCMetadata,metadataConnection,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,true));
        MetadataFillFactory.getDBInstance(currentEDatabaseType).fillSchemas(copyedConnection,dbJDBCMetadata,metadataConnection,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,false));
        ConnectionUtils.closeConnection(sqlConn);
      }
 else {
        returnProvider.setMessage(trc.getMessage());
      }
    }
  }
  if (copyedConnection == null) {
    returnProvider.setOk(false);
  }
 else {
    returnProvider.setObject(copyedConnection);
  }
  return returnProvider;
}

Fixed version (ground truth):
public static TypedReturnCode<Connection> getRefreshedDataProvider(Connection prevDataProvider){
  TypedReturnCode<Connection> returnProvider=new TypedReturnCode<Connection>();
  boolean mdm=ConnectionUtils.isMdmConnection(prevDataProvider);
  IMetadataConnection metadataConnection=ConvertionHelper.convert((DatabaseConnection)prevDataProvider,false,prevDataProvider.getContextName());
  Connection copyedConnection=null;
  if (mdm) {
    copyedConnection=MetadataFillFactory.getMDMInstance().fillUIConnParams(metadataConnection,null);
    MetadataFillFactory.getMDMInstance().fillSchemas(copyedConnection,null,null);
  }
 else {
    EDatabaseTypeName currentEDatabaseType=EDatabaseTypeName.getTypeFromDbType(metadataConnection.getDbType());
    if (currentEDatabaseType != null) {
      MetadataFillFactory dbInstance=MetadataFillFactory.getDBInstance(metadataConnection);
      TypedReturnCode<?> trc=(TypedReturnCode<?>)dbInstance.createConnection(metadataConnection);
      Object sqlConnObject=trc.getObject();
      DatabaseMetaData dbJDBCMetadata=null;
      if (trc.isOk() && sqlConnObject instanceof java.sql.Connection) {
        java.sql.Connection sqlConn=(java.sql.Connection)sqlConnObject;
        dbJDBCMetadata=ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConn,(DatabaseConnection)prevDataProvider);
        copyedConnection=EObjectHelper.deepCopy(prevDataProvider);
        copyedConnection.getDataPackage().clear();
        dbInstance.fillCatalogs(copyedConnection,dbJDBCMetadata,metadataConnection,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,true));
        dbInstance.fillSchemas(copyedConnection,dbJDBCMetadata,metadataConnection,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,false));
        ConnectionUtils.closeConnection(sqlConn);
      }
 else {
        returnProvider.setMessage(trc.getMessage());
      }
    }
  }
  if (copyedConnection == null) {
    returnProvider.setOk(false);
  }
 else {
    returnProvider.setObject(copyedConnection);
  }
  return returnProvider;
}