Program: 95827
Project: 95827
Buggy source:
/** 
 * @return true if successfull; false otherwise
 */
private static boolean connectToDB(){
  Job connectToDBJob=new Job(Messages.ConnectingToDatabaseJob){
    protected IStatus run(    IProgressMonitor monitor){
      Integer message=0;
      try {
        instance(user,pw,dburl,monitor);
        user=null;
        pw=null;
        if (instance.m_newDbSchemeInstalled) {
          instance.m_newDbSchemeInstalled=false;
          DatabaseStateDispatcher.notifyListener(new DatabaseStateEvent(DatabaseState.DB_SCHEME_CREATED));
        }
        return Status.OK_STATUS;
      }
 catch (      PMDatabaseConfException e) {
        if (e.getErrorId().equals(MessageIDs.E_INVALID_DB_VERSION)) {
          message=MessageIDs.E_INVALID_DB_VERSION;
        }
 else         if (e.getErrorId().equals(MessageIDs.E_NOT_CHECKABLE_DB_VERSION)) {
          message=MessageIDs.E_NOT_CHECKABLE_DB_VERSION;
        }
 else         if (e.getErrorId().equals(MessageIDs.E_NO_DB_SCHEME)) {
          message=MessageIDs.E_NO_DB_SCHEME;
        }
 else         if (e.getErrorId().equals(MessageIDs.E_ERROR_IN_SCHEMA_CONFIG)) {
          message=MessageIDs.E_ERROR_IN_SCHEMA_CONFIG;
        }
 else {
          message=MessageIDs.E_UNEXPECTED_EXCEPTION;
        }
        return new Status(IStatus.ERROR,Activator.PLUGIN_ID,message.toString(),e);
      }
catch (      JBException e) {
        if (e.getErrorId().equals(MessageIDs.E_NO_DB_CONNECTION)) {
          message=MessageIDs.E_NO_DB_CONNECTION;
        }
        if (e.getErrorId().equals(MessageIDs.E_DB_IN_USE)) {
          message=MessageIDs.E_DB_IN_USE;
        }
        return new Status(IStatus.ERROR,Activator.PLUGIN_ID,message.toString(),e);
      }
    }
  }
;
  final AtomicBoolean connectionGained=new AtomicBoolean();
  connectToDBJob.addJobChangeListener(new JobChangeListener(){
    /** 
 * {@inheritDoc} 
 */
    public void done(    IJobChangeEvent event){
      connectionGained.set(event.getResult().isOK());
    }
  }
);
  connectToDBJob.setUser(true);
  connectToDBJob.schedule();
  try {
    connectToDBJob.join();
  }
 catch (  InterruptedException e) {
    log.error(e.getLocalizedMessage(),e);
    connectionGained.set(false);
  }
  return connectionGained.get();
}

Fixed version (ground truth):
/** 
 * @return true if successful; false otherwise
 */
private static boolean connectToDB(){
  Job connectToDBJob=new Job(Messages.ConnectingToDatabaseJob){
    protected IStatus run(    IProgressMonitor monitor){
      Integer message=0;
      try {
        instance(user,pw,dburl,monitor);
        user=null;
        pw=null;
        if (instance.m_newDbSchemeInstalled) {
          instance.m_newDbSchemeInstalled=false;
          DatabaseStateDispatcher.notifyListener(new DatabaseStateEvent(DatabaseState.DB_SCHEME_CREATED));
        }
        return Status.OK_STATUS;
      }
 catch (      PMDatabaseConfException e) {
        if (e.getErrorId().equals(MessageIDs.E_INVALID_DB_VERSION)) {
          message=MessageIDs.E_INVALID_DB_VERSION;
        }
 else         if (e.getErrorId().equals(MessageIDs.E_NOT_CHECKABLE_DB_VERSION)) {
          message=MessageIDs.E_NOT_CHECKABLE_DB_VERSION;
        }
 else         if (e.getErrorId().equals(MessageIDs.E_NO_DB_SCHEME)) {
          message=MessageIDs.E_NO_DB_SCHEME;
        }
 else         if (e.getErrorId().equals(MessageIDs.E_ERROR_IN_SCHEMA_CONFIG)) {
          message=MessageIDs.E_ERROR_IN_SCHEMA_CONFIG;
        }
 else {
          message=MessageIDs.E_UNEXPECTED_EXCEPTION;
        }
        return new Status(IStatus.ERROR,Activator.PLUGIN_ID,message.toString(),e);
      }
catch (      JBException e) {
        if (e.getErrorId().equals(MessageIDs.E_NO_DB_CONNECTION)) {
          message=MessageIDs.E_NO_DB_CONNECTION;
        }
        if (e.getErrorId().equals(MessageIDs.E_DB_IN_USE)) {
          message=MessageIDs.E_DB_IN_USE;
        }
        return new Status(IStatus.ERROR,Activator.PLUGIN_ID,message.toString(),e);
      }
    }
  }
;
  final AtomicBoolean connectionGained=new AtomicBoolean();
  connectToDBJob.addJobChangeListener(new JobChangeListener(){
    /** 
 * {@inheritDoc} 
 */
    public void done(    IJobChangeEvent event){
      connectionGained.set(event.getResult().isOK());
    }
  }
);
  connectToDBJob.setUser(true);
  connectToDBJob.schedule();
  try {
    connectToDBJob.join();
  }
 catch (  InterruptedException e) {
    log.error(e.getLocalizedMessage(),e);
    connectionGained.set(false);
  }
  return connectionGained.get();
}