Program: 124592
Project: 124592
Buggy source:
public static synchronized Object getDB(NoSQLConnection connection) throws NoSQLServerException {
  Object db=null;
  ClassLoader classLoader=NoSQLClassLoaderFactory.getClassLoader(connection);
  try {
    boolean isRemote=Boolean.valueOf(connection.getAttributes().get(INeo4jAttributes.REMOTE_SERVER));
    if (isRemote) {
      String serverUrl=StringUtils.trimToEmpty(connection.getAttributes().get(INeo4jAttributes.SERVER_URL));
      if (connection.isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection);
        serverUrl=ContextParameterUtils.getOriginalValue(contextType,serverUrl);
      }
      if (isNeedAuthorization(connection)) {
        String usename=StringUtils.trimToEmpty(connection.getAttributes().get(INeo4jAttributes.USERNAME));
        String password=StringUtils.trimToEmpty(connection.getAttributes().get(INeo4jAttributes.PASSWORD));
        if (connection.isContextMode()) {
          ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection);
          usename=ContextParameterUtils.getOriginalValue(contextType,usename);
          password=ContextParameterUtils.getOriginalValue(contextType,password);
        }
 else {
          password=connection.getValue(password,false);
        }
        db=NoSQLReflection.newInstance("String_Node_Str",new Object[]{serverUrl,usename,password},classLoader);
      }
 else {
        db=NoSQLReflection.newInstance("String_Node_Str",new Object[]{serverUrl},classLoader);
      }
    }
 else {
      String dbPath=StringUtils.trimToEmpty(connection.getAttributes().get(INeo4jAttributes.DATABASE_PATH));
      if (connection.isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection);
        dbPath=ContextParameterUtils.getOriginalValue(contextType,dbPath);
      }
      Object dbFactory=NoSQLReflection.newInstance("String_Node_Str",new Object[0],classLoader);
      db=NoSQLReflection.invokeMethod(dbFactory,"String_Node_Str",new Object[]{dbPath});
    }
    registerShutdownHook(db);
  }
 catch (  NoSQLReflectionException e) {
    throw new NoSQLServerException(e);
  }
  return graphDb=db;
}

Fixed version (ground truth):
public static synchronized Object getDB(NoSQLConnection connection,boolean useCache) throws NoSQLServerException {
  if (useCache && graphDb != null) {
    return graphDb;
  }
  Object db=null;
  ClassLoader classLoader=NoSQLClassLoaderFactory.getClassLoader(connection);
  try {
    boolean isRemote=Boolean.valueOf(connection.getAttributes().get(INeo4jAttributes.REMOTE_SERVER));
    if (isRemote) {
      String serverUrl=StringUtils.trimToEmpty(connection.getAttributes().get(INeo4jAttributes.SERVER_URL));
      if (connection.isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection);
        serverUrl=ContextParameterUtils.getOriginalValue(contextType,serverUrl);
      }
      if (isNeedAuthorization(connection)) {
        String usename=StringUtils.trimToEmpty(connection.getAttributes().get(INeo4jAttributes.USERNAME));
        String password=StringUtils.trimToEmpty(connection.getAttributes().get(INeo4jAttributes.PASSWORD));
        if (connection.isContextMode()) {
          ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection);
          usename=ContextParameterUtils.getOriginalValue(contextType,usename);
          password=ContextParameterUtils.getOriginalValue(contextType,password);
        }
 else {
          password=connection.getValue(password,false);
        }
        db=NoSQLReflection.newInstance("String_Node_Str",new Object[]{serverUrl,usename,password},classLoader);
      }
 else {
        db=NoSQLReflection.newInstance("String_Node_Str",new Object[]{serverUrl},classLoader);
      }
    }
 else {
      String dbPath=StringUtils.trimToEmpty(connection.getAttributes().get(INeo4jAttributes.DATABASE_PATH));
      if (connection.isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connection);
        dbPath=ContextParameterUtils.getOriginalValue(contextType,dbPath);
      }
      Object dbFactory=NoSQLReflection.newInstance("String_Node_Str",new Object[0],classLoader);
      db=NoSQLReflection.invokeMethod(dbFactory,"String_Node_Str",new Object[]{dbPath});
    }
    registerShutdownHook(db);
  }
 catch (  NoSQLReflectionException e) {
    throw new NoSQLServerException(e);
  }
  return graphDb=db;
}