Program: 145407
Project: 145407
Buggy source:
public static Map<String,String> getUserProperties(DatabasesClient aClient,String aUserName,Scripts.Space aSpace,Consumer<Map<String,String>> onSuccess,Consumer<Exception> onFailure) throws Exception {
  if (aUserName != null && aClient != null) {
    final SqlQuery q=new SqlQuery(aClient,USER_QUERY_TEXT);
    q.putParameter(USERNAME_PARAMETER_NAME,DataTypeInfo.VARCHAR,aUserName.toUpperCase());
    aClient.initUsersSpace(q.getDatasourceName());
    SqlCompiledQuery compiled=q.compile();
    CallableConsumer<Map<String,String>,ResultSet> doWork=(    ResultSet r) -> {
      Map<String,String> properties=new HashMap<>();
      ColumnsIndicies idxs=new ColumnsIndicies(r.getMetaData());
      if (r.next()) {
        properties.put(ClientConstants.F_USR_NAME,aUserName);
        properties.put(ClientConstants.F_USR_CONTEXT,r.getString(idxs.find(ClientConstants.F_USR_CONTEXT)));
        properties.put(ClientConstants.F_USR_EMAIL,r.getString(idxs.find(ClientConstants.F_USR_EMAIL)));
        properties.put(ClientConstants.F_USR_PHONE,r.getString(idxs.find(ClientConstants.F_USR_PHONE)));
        properties.put(ClientConstants.F_USR_FORM,r.getString(idxs.find(ClientConstants.F_USR_FORM)));
        properties.put(ClientConstants.F_USR_PASSWD,r.getString(idxs.find(ClientConstants.F_USR_PASSWD)));
      }
      return properties;
    }
;
    if (onSuccess != null) {
      compiled.<Map<String,String>>executeQuery(doWork,(      Runnable aTask) -> {
        aSpace.process(aTask);
      }
,(      Map<String,String> props) -> {
        onSuccess.accept(props);
      }
,onFailure);
      return null;
    }
 else {
      return compiled.<Map<String,String>>executeQuery(doWork,null,null,null);
    }
  }
 else {
    if (onSuccess != null) {
      aSpace.process(() -> {
        onSuccess.accept(new HashMap<>());
      }
);
      return null;
    }
 else {
      return null;
    }
  }
}

Fixed version (ground truth):
public static Map<String,String> getUserProperties(DatabasesClient aClient,String aUserName,Scripts.Space aSpace,Consumer<Map<String,String>> onSuccess,Consumer<Exception> onFailure) throws Exception {
  if (aUserName != null && aClient != null) {
    final SqlQuery q=new SqlQuery(aClient,USER_QUERY_TEXT);
    q.putParameter(USERNAME_PARAMETER_NAME,DataTypeInfo.VARCHAR,aUserName.toUpperCase());
    SqlCompiledQuery compiled=q.compile();
    CallableConsumer<Map<String,String>,ResultSet> doWork=(    ResultSet r) -> {
      Map<String,String> properties=new HashMap<>();
      ColumnsIndicies idxs=new ColumnsIndicies(r.getMetaData());
      if (r.next()) {
        properties.put(ClientConstants.F_USR_NAME,aUserName);
        properties.put(ClientConstants.F_USR_CONTEXT,r.getString(idxs.find(ClientConstants.F_USR_CONTEXT)));
        properties.put(ClientConstants.F_USR_EMAIL,r.getString(idxs.find(ClientConstants.F_USR_EMAIL)));
        properties.put(ClientConstants.F_USR_PHONE,r.getString(idxs.find(ClientConstants.F_USR_PHONE)));
        properties.put(ClientConstants.F_USR_FORM,r.getString(idxs.find(ClientConstants.F_USR_FORM)));
        properties.put(ClientConstants.F_USR_PASSWD,r.getString(idxs.find(ClientConstants.F_USR_PASSWD)));
      }
      return properties;
    }
;
    if (onSuccess != null) {
      try {
        compiled.<Map<String,String>>executeQuery(doWork,(        Runnable aTask) -> {
          aSpace.process(aTask);
        }
,onSuccess,onFailure);
        return null;
      }
 catch (      Exception ex) {
        aSpace.process(() -> {
          onFailure.accept(ex);
        }
);
        return null;
      }
    }
 else {
      return compiled.<Map<String,String>>executeQuery(doWork,null,null,null);
    }
  }
 else {
    if (onSuccess != null) {
      aSpace.process(() -> {
        onSuccess.accept(new HashMap<>());
      }
);
      return null;
    }
 else {
      return null;
    }
  }
}