You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you forget to instrument the code, the wrong warning message is printed:
WARN com.ea.async.Async - Warning: Illegal call to await, the method invoking await must return a CompletableFuture
instead of
Warning: Illegal call to await, static { Async.init(); } must be added to the main program class and the method invoking await must return a CompletableFuture
This is because calling InitializeAsync.isRunning() triggers the class initialization, and only enters that method once isRunning = true. The only ways to have isRunning() returning false is if either the initialization crashes or if called from multiple threads.
In addition, I think it would be better to throw an exception than calling join(). In the above example this causes a deadlock, and you don't know which method it is referring to.
The text was updated successfully, but these errors were encountered:
It also seems like if you have instrumented your code it will always give:
WARN com.ea.async.Async - Warning: Illegal call to await, the method invoking await must return a CompletableFuture
I am not sure if the else part should have been something like below instead
if (!InitializeAsync.isRunning()) {
warning = "Warning: Illegal call to await, static { Async.init(); } must be added to the main program class and the method invoking await must return a CompletableFuture";
} else if (!(future instanceof CompletableFuture)) {
warning = "Warning: Illegal call to await, the method invoking await must return a CompletableFuture";
}
If you forget to instrument the code, the wrong warning message is printed:
instead of
As shown by the following simple example:
This is because calling
InitializeAsync.isRunning()
triggers the class initialization, and only enters that method onceisRunning = true
. The only ways to haveisRunning()
returning false is if either the initialization crashes or if called from multiple threads.In addition, I think it would be better to throw an exception than calling
join()
. In the above example this causes a deadlock, and you don't know which method it is referring to.The text was updated successfully, but these errors were encountered: