Program: 145390
Project: 145390
Buggy source:
@Override public void handle(Session aSession,Consumer<CommitRequest.Response> onSuccess,Consumer<Exception> onFailure){
  try {
    DatabasesClient client=getServerCore().getDatabasesClient();
    List<Change> changes=ChangesJSONReader.read(getRequest().getChangesJson(),Scripts.getSpace());
    ChangesSortProcess process=new ChangesSortProcess(changes,(    Map<String,List<Change>> changeLogs) -> {
      try {
        client.commit(changeLogs,(        Integer aUpdated) -> {
          if (onSuccess != null) {
            onSuccess.accept(new CommitRequest.Response(aUpdated));
          }
        }
,onFailure);
      }
 catch (      Exception ex) {
        Logger.getLogger(CommitRequestHandler.class.getName()).log(Level.SEVERE,null,ex);
      }
    }
,onFailure);
    if (changes.isEmpty()) {
      if (onSuccess != null) {
        onSuccess.accept(new CommitRequest.Response(0));
      }
    }
 else {
      changes.stream().forEach((change) -> {
        try {
          ((LocalQueriesProxy)serverCore.getQueries()).getQuery(change.entityName,Scripts.getSpace(),(          SqlQuery aQuery) -> {
            if (aQuery.isPublicAccess()) {
              AccessControlException aex=checkWritePrincipalPermission((PlatypusPrincipal)Scripts.getContext().getPrincipal(),change.entityName,aQuery.getWriteRoles());
              if (aex != null) {
                process.complete(null,null,aex,null);
              }
 else {
                process.complete(change,aQuery,null,null);
              }
            }
 else {
              process.complete(null,null,new AccessControlException(String.format("String_Node_Str",change.entityName)),null);
            }
          }
,(          Exception ex) -> {
            process.complete(null,null,null,ex);
          }
);
        }
 catch (        Exception ex) {
          Logger.getLogger(CommitRequestHandler.class.getName()).log(Level.SEVERE,null,ex);
        }
      }
);
    }
  }
 catch (  Exception ex) {
    onFailure.accept(ex);
  }
}

Fixed version (ground truth):
@Override public void handle(Session aSession,Consumer<CommitRequest.Response> onSuccess,Consumer<Exception> onFailure){
  try {
    DatabasesClient client=getServerCore().getDatabasesClient();
    List<Change> changes=ChangesJSONReader.read(getRequest().getChangesJson(),Scripts.getSpace());
    ChangesSortProcess process=new ChangesSortProcess(changes,client.getDefaultDatasourceName(),(    Map<String,List<Change>> changeLogs) -> {
      try {
        client.commit(changeLogs,(        Integer aUpdated) -> {
          if (onSuccess != null) {
            onSuccess.accept(new CommitRequest.Response(aUpdated));
          }
        }
,onFailure);
      }
 catch (      Exception ex) {
        Logger.getLogger(CommitRequestHandler.class.getName()).log(Level.SEVERE,null,ex);
      }
    }
,onFailure);
    if (changes.isEmpty()) {
      if (onSuccess != null) {
        onSuccess.accept(new CommitRequest.Response(0));
      }
    }
 else {
      changes.stream().forEach((change) -> {
        try {
          ((LocalQueriesProxy)serverCore.getQueries()).getQuery(change.entityName,Scripts.getSpace(),(          SqlQuery aQuery) -> {
            if (aQuery.isPublicAccess()) {
              AccessControlException aex=checkWritePrincipalPermission((PlatypusPrincipal)Scripts.getContext().getPrincipal(),change.entityName,aQuery.getWriteRoles());
              if (aex != null) {
                process.complete(null,null,aex,null);
              }
 else {
                process.complete(change,aQuery,null,null);
              }
            }
 else {
              process.complete(null,null,new AccessControlException(String.format("String_Node_Str",change.entityName)),null);
            }
          }
,(          Exception ex) -> {
            process.complete(null,null,null,ex);
          }
);
        }
 catch (        Exception ex) {
          Logger.getLogger(CommitRequestHandler.class.getName()).log(Level.SEVERE,null,ex);
        }
      }
);
    }
  }
 catch (  Exception ex) {
    onFailure.accept(ex);
  }
}