You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/06/01 13:15:05 UTC

[GitHub] [netbeans] mbien commented on a diff in pull request #4180: Improve output window performance for ant java tasks #4141.

mbien commented on code in PR #4180:
URL: https://github.com/apache/netbeans/pull/4180#discussion_r886792318


##########
extide/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/ForkedJavaOverride.java:
##########
@@ -162,228 +166,222 @@ public synchronized void setError(File[] error) {
 
         private class NbOutputStreamHandler implements ExecuteStreamHandler {
 
-            private Thread outTask;
-            private Thread errTask;
-            private Thread inTask;
-            private Copier outCopier, errCopier; // #212526
-            private FoldingHelper foldingHelper;
-
+            private final ExecutorService tasks;
+            private final FoldingHelper foldingHelper;
+            private Future inputTask;
+            private InputStream stdout, stderr;
+            private OutputStream stdin;
+            
             NbOutputStreamHandler() {
                 this.foldingHelper = new FoldingHelper();
+                this.tasks = Executors.newFixedThreadPool(3, (r) -> {
+                    Thread t = new Thread(Thread.currentThread().getThreadGroup(),
+                        r,
+                        "I/O Thread for " + getProject().getName()); // NOI18N
+                    t.setDaemon(true);
+                    return t;
+                });
             }
 
-            public void start() throws IOException {}
+            private void setCopier(InputStream inputStream, OutputStream os, boolean delegate, boolean err) {
+                if (os == null || delegate) {
+                    tasks.submit(new TransferCopier(inputStream, AntBridge.delegateOutputStream(err)));
+                } else {
+                    tasks.submit(new TransferCopier(inputStream, os));
+                }
+            }
+
+            public void start() throws IOException {
+                getProject().getBuildListeners().stream()
+                    .filter(o -> o instanceof NbBuildLogger)
+                    .map(o -> (NbBuildLogger)o)
+                    .findFirst().ifPresentOrElse(buildLogger -> {
+                        tasks.submit(new MarkupCopier(stdout, Project.MSG_INFO, false, outEncoding, buildLogger, foldingHelper));
+                        tasks.submit(new MarkupCopier(stderr, Project.MSG_WARN, true, outEncoding, buildLogger, foldingHelper));
+                    }, ()->{

Review Comment:
   `ifPresentOrElse` is Java 9. Some modules have to stay compatible with Java 8 still, unfortunately. (thats the reason why the build fails)



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists