mbien opened a new pull request, #7030:
URL: https://github.com/apache/netbeans/pull/7030
the internal `GradleTask` appears to cover s similar usecase as the
`CompletableFuture` class. The implementation however caused a three
state race condition:
- executor calls `finish(int)` before someone calls `result()`: this
seems to be the intended usecase to create a fast-path which
finishes the task early
- result() is called before `finish(int)`: this will block on the
wrapped task and finish has no effect. This behavior can be
reproduced by attempting to delete a gradle project, the delete
project dialog will stay open for almost a minute.
- third state is when `createTask()` is called too late: this will cause
a NPE since the task is already started via `setTask()`, the
executor would try to call finish on a task wrapper which is null.
Can be easily reproduced by setting a breakpoint in the codepath
which calls `createTask()` or the method itself
example:
```
java.lang.NullPointerException: Cannot invoke
"org.netbeans.modules.gradle.execute.GradleDaemonExecutor$GradleTask.finish(int)"
because "this.gradleTask" is null
at
org.netbeans.modules.gradle.execute.GradleDaemonExecutor.run(GradleDaemonExecutor.java:263)
at
org.netbeans.core.execution.RunClassThread.doRun(RunClassThread.java:132)
at
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
[catch] at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:81)
```
fixes:
- block on `CountDownLatch` instead of delegate
- create wrapper right when the task starts
- the other commit fixes an issue where a `start()` is called from within
the thread's constructor
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists