Program: 137351
Project: 137351
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 {
    SupportDBUrlType currentDBUrlType=SupportDBUrlType.getDBTypeByKey(metadataConnection.getDbType());
    TypedReturnCode<?> trc=(TypedReturnCode<?>)MetadataFillFactory.getDBInstance(SupportDBUrlType.getDBTypeByKey(metadataConnection.getDbType())).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(currentDBUrlType).fillCatalogs(copyedConnection,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,true));
      MetadataFillFactory.getDBInstance(currentDBUrlType).fillSchemas(copyedConnection,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,false));
      ConnectionUtils.closeConnection(sqlConn);
    }
  }
  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(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,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,true));
        MetadataFillFactory.getDBInstance(currentEDatabaseType).fillSchemas(copyedConnection,dbJDBCMetadata,MetadataConnectionUtils.getPackageFilter(copyedConnection,dbJDBCMetadata,false));
        ConnectionUtils.closeConnection(sqlConn);
      }
    }
  }
  if (copyedConnection == null) {
    returnProvider.setOk(false);
  }
 else {
    returnProvider.setObject(copyedConnection);
  }
  return returnProvider;
}