Program: 145397
Project: 145397
Buggy source:
@Override protected ApplyResult apply(final String aDatasourceName,final List<Change> aLog,Scripts.Space aSpace,Consumer<ApplyResult> onSuccess,Consumer<Exception> onFailure) throws Exception {
  if (onSuccess != null) {
    validate(aDatasourceName,aLog,(    Void v) -> {
      try {
        AppElementFiles files=indexer.nameToFiles(aDatasourceName);
        if (files != null && files.isModule()) {
          JSObject module=createModule(aDatasourceName,aSpace);
          if (module != null) {
            Object oApply=module.getMember("String_Node_Str");
            if (oApply instanceof JSObject && ((JSObject)oApply).isFunction()) {
              JSObject applyFunction=(JSObject)oApply;
              aSpace.toJava(applyFunction.call(module,new Object[]{aSpace.toJs(aLog.toArray()),new AbstractJSObject(){
                @Override public Object call(                final Object thiz,                final Object... args){
                  int affected=0;
                  if (args.length > 0) {
                    Object oAffected=aSpace.toJava(args[0]);
                    if (oAffected instanceof Number) {
                      affected=((Number)oAffected).intValue();
                    }
                  }
                  onSuccess.accept(new ApplyResult(affected,new DummySqlConnection()));
                  return null;
                }
              }
,new AbstractJSObject(){
                @Override public Object call(                final Object thiz,                final Object... args){
                  if (onFailure != null) {
                    if (args.length > 0) {
                      if (args[0] instanceof Exception) {
                        onFailure.accept((Exception)args[0]);
                      }
 else {
                        onFailure.accept(new Exception(String.valueOf(aSpace.toJava(args[0]))));
                      }
                    }
 else {
                      onFailure.accept(new Exception("String_Node_Str"));
                    }
                  }
                  return null;
                }
              }
}));
            }
 else {
              onFailure.accept(new IllegalStateException(String.format(APPLY_MISSING_MSG,aDatasourceName)));
            }
          }
 else {
            onFailure.accept(new IllegalStateException(String.format(CANT_CREATE_MODULE_MSG,aDatasourceName)));
          }
        }
 else {
          super.apply(aDatasourceName,aLog,aSpace,onSuccess,onFailure);
        }
      }
 catch (      Exception ex) {
        onFailure.accept(ex);
      }
    }
,onFailure,aSpace);
    return null;
  }
 else {
    validate(aDatasourceName,aLog,null,null,aSpace);
    AppElementFiles files=indexer.nameToFiles(aDatasourceName);
    if (files != null && files.isModule()) {
      JSObject module=createModule(aDatasourceName,aSpace);
      if (module != null) {
        Object oApply=module.getMember("String_Node_Str");
        if (oApply instanceof JSObject && ((JSObject)oApply).isFunction()) {
          JSObject applyFunction=(JSObject)oApply;
          int affectedInModules=0;
          Object oAffected=aSpace.toJava(applyFunction.call(module,new Object[]{aSpace.toJs(aLog.toArray())}));
          if (oAffected instanceof Number) {
            affectedInModules=((Number)oAffected).intValue();
          }
          return new ApplyResult(affectedInModules,new DummySqlConnection());
        }
 else {
          throw new IllegalStateException(String.format(APPLY_MISSING_MSG,aDatasourceName));
        }
      }
 else {
        throw new IllegalStateException(String.format(CANT_CREATE_MODULE_MSG,aDatasourceName));
      }
    }
 else {
      return super.apply(aDatasourceName,aLog,null,null,null);
    }
  }
}

Fixed version (ground truth):
@Override protected ApplyResult apply(final String aDatasourceName,final List<Change> aLog,Scripts.Space aSpace,Consumer<ApplyResult> onSuccess,Consumer<Exception> onFailure) throws Exception {
  if (onSuccess != null) {
    validate(aDatasourceName,aLog,(    Void v) -> {
      try {
        AppElementFiles files=indexer.nameToFiles(aDatasourceName);
        if (files != null && files.isModule()) {
          JSObject module=createModule(aDatasourceName,aSpace);
          if (module != null) {
            Object oApply=module.getMember("String_Node_Str");
            if (oApply instanceof JSObject && ((JSObject)oApply).isFunction()) {
              JSObject applyFunction=(JSObject)oApply;
              aSpace.toJava(applyFunction.call(module,new Object[]{aSpace.toJs(aLog.toArray()),new AbstractJSObject(){
                @Override public Object call(                final Object thiz,                final Object... args){
                  int affected=0;
                  if (args.length > 0) {
                    Object oAffected=aSpace.toJava(args[0]);
                    if (oAffected instanceof Number) {
                      affected=((Number)oAffected).intValue();
                    }
                  }
                  onSuccess.accept(new ApplyResult(affected,new DummySqlConnection(),true));
                  return null;
                }
              }
,new AbstractJSObject(){
                @Override public Object call(                final Object thiz,                final Object... args){
                  if (onFailure != null) {
                    if (args.length > 0) {
                      if (args[0] instanceof Exception) {
                        onFailure.accept((Exception)args[0]);
                      }
 else {
                        onFailure.accept(new Exception(String.valueOf(aSpace.toJava(args[0]))));
                      }
                    }
 else {
                      onFailure.accept(new Exception("String_Node_Str"));
                    }
                  }
                  return null;
                }
              }
}));
            }
 else {
              onFailure.accept(new IllegalStateException(String.format(APPLY_MISSING_MSG,aDatasourceName)));
            }
          }
 else {
            onFailure.accept(new IllegalStateException(String.format(CANT_CREATE_MODULE_MSG,aDatasourceName)));
          }
        }
 else {
          super.apply(aDatasourceName,aLog,aSpace,onSuccess,onFailure);
        }
      }
 catch (      Exception ex) {
        onFailure.accept(ex);
      }
    }
,onFailure,aSpace);
    return null;
  }
 else {
    validate(aDatasourceName,aLog,null,null,aSpace);
    AppElementFiles files=indexer.nameToFiles(aDatasourceName);
    if (files != null && files.isModule()) {
      JSObject module=createModule(aDatasourceName,aSpace);
      if (module != null) {
        Object oApply=module.getMember("String_Node_Str");
        if (oApply instanceof JSObject && ((JSObject)oApply).isFunction()) {
          JSObject applyFunction=(JSObject)oApply;
          int affectedInModules=0;
          Object oAffected=aSpace.toJava(applyFunction.call(module,new Object[]{aSpace.toJs(aLog.toArray())}));
          if (oAffected instanceof Number) {
            affectedInModules=((Number)oAffected).intValue();
          }
          return new ApplyResult(affectedInModules,new DummySqlConnection(),true);
        }
 else {
          throw new IllegalStateException(String.format(APPLY_MISSING_MSG,aDatasourceName));
        }
      }
 else {
        throw new IllegalStateException(String.format(CANT_CREATE_MODULE_MSG,aDatasourceName));
      }
    }
 else {
      return super.apply(aDatasourceName,aLog,null,null,null);
    }
  }
}