dojo / util

Dojo 1 - build utilities. Please submit bugs to https://bugs.dojotoolkit.org/
https://dojotoolkit.org/
Other
60 stars 105 forks source link

Fixes #19025, optimizeRunner.js catches IllegalArgumentException in shutdownClosureExecutorService #62

Closed sindilevich closed 7 years ago

sindilevich commented 7 years ago

The https://github.com/dojo/util/commit/d81fb9e35b1a089a0e81c24ce73c4f16d6754842 commit does not eliminate an exception being thrown by the shutdownClosureExecutorService() function. Now it simply throws another exception.

The deal is, the shutdown() method is defined on private static ExecutorService com.google.javascript.jscomp.Compiler.compilerExecutor.compilerExecutor.

Thus, the correct function body for the shutdownClosureExecutorService() function should be as follows:

function shutdownClosureExecutorService(){
    try{
        var compilerClass = java.lang.Class.forName("com.google.javascript.jscomp.Compiler");
        var compilerExecutorField = compilerClass.getDeclaredField("compilerExecutor");
        compilerExecutorField.setAccessible(true);
        var compilerExecutor = compilerExecutorField.get(compiler);
        compilerClass = compilerExecutor.getClass();
        compilerExecutorField = compilerClass.getDeclaredField("compilerExecutor");
        compilerExecutorField.setAccessible(true);
        compilerExecutor = compilerExecutorField.get(compilerExecutor);
        compilerExecutor.shutdown();
    }catch (e){
        print(e);
        if("javaException" in e){
            e.javaException.printStackTrace();
        }
    }
}

Also, when we move to a newer version of the Google Closure Compiler, one newer than https://github.com/google/closure-compiler/commit/7bdbe963715ade06047c247065e43170933cf5e1, the whole shutdownClosureExecutorService() function becomes obsolete, as they shutting down the executor service by themselves from there on, if I understand correctly.

dylans commented 7 years ago

Thanks for the PR @sindilevich ... interesting issue with the newer versions of Closure Compiler. I think these issues have been particularly difficult to track down, in part because we don't really have a test suite for all of this that is easy to run. Regardless, we'll review and hopefully land the PR as-is.

dylans commented 7 years ago

Thanks! Closed via 6d397fb. Backported as c7e6a30 (1.12).