sdedic commented on code in PR #7030:
URL: https://github.com/apache/netbeans/pull/7030#discussion_r1479368186


##########
extide/gradle/src/org/netbeans/modules/gradle/execute/GradleDaemonExecutor.java:
##########
@@ -439,41 +441,70 @@ private static String gradleExecutable() {
         return Utilities.isWindows() ? "bin\\gradle.bat" : "bin/gradle"; 
//NOI18N
     }
 
-    public final ExecutorTask createTask(ExecutorTask process) {
+    // TODO one of the two methods can likely go from the API
+    // setTask is called first and signals the runnable to start
+    // the started runnable requires (!) the gradleTask so it can't be created 
in createTask
+    @Override
+    public void setTask(ExecutorTask task) {
         assert gradleTask == null;
-        gradleTask = new GradleTask(process);
+        gradleTask = new GradleTask(task);
+        super.setTask(task);
+    }
+
+    @Override
+    public final ExecutorTask createTask(ExecutorTask process) {
+        assert gradleTask != null;
+        assert task == process;
         return gradleTask;
     }
 
+    // task which can finish early, like a CompletableFuture
     private static final class GradleTask extends ExecutorTask {
-        private final ExecutorTask delegate;
-        private Integer result;
 
+        private final ExecutorTask delegate;
+        private volatile Integer result;
+        // is 0 when wrapper or delegate finished
+        private final CountDownLatch doneSignal = new CountDownLatch(1);
+        
         GradleTask(ExecutorTask delegate) {
             super(() -> {});
             this.delegate = delegate;
+            this.delegate.addTaskListener(t -> doneSignal.countDown());

Review Comment:
   In this case, if called before finish, the `result` will appear to be 0 == 
success. Is that OK ? When searching for `finish` calls, I've found  paths in 
`GradleDaemonExecutor::run` - the exception handlers, that do not call 
gradleTask.finish at all, so these all will reach this lambda and produce 
result 0 ?



-- 
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

Reply via email to