You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by mb...@apache.org on 2022/12/08 20:00:45 UTC

[netbeans] branch master updated: Avoid an `AssertionError` with Maven folds

This is an automated email from the ASF dual-hosted git repository.

mbien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 14e482508d Avoid an `AssertionError` with Maven folds
     new 8bec57f9a0 Merge pull request #4957 from jglick/foldsBroken
14e482508d is described below

commit 14e482508deae6c777a9ac16e56c6c1a39ff0d69
Author: Jesse Glick <jg...@apache.org>
AuthorDate: Thu Nov 10 15:13:37 2022 -0500

    Avoid an `AssertionError` with Maven folds
---
 .../modules/maven/execute/CommandLineOutputHandler.java  |  8 ++++++--
 .../modules/maven/execute/cmd/ExecutionEventObject.java  | 16 +++++++++++-----
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/java/maven/src/org/netbeans/modules/maven/execute/CommandLineOutputHandler.java b/java/maven/src/org/netbeans/modules/maven/execute/CommandLineOutputHandler.java
index 8ad34b0a29..9c0b169c4e 100644
--- a/java/maven/src/org/netbeans/modules/maven/execute/CommandLineOutputHandler.java
+++ b/java/maven/src/org/netbeans/modules/maven/execute/CommandLineOutputHandler.java
@@ -107,6 +107,7 @@ public class CommandLineOutputHandler extends AbstractOutputHandler {
     private boolean inStackTrace = false;
     private boolean addMojoFold = false;
     private boolean addProjectFold = false;
+    private boolean foldsBroken;
     private URL[] mavencoreurls;
 
     public CommandLineOutputHandler(InputOutput io, Project proj, ProgressHandle hand, RunConfig config, boolean createVisitorContext) {
@@ -350,11 +351,11 @@ public class CommandLineOutputHandler extends AbstractOutputHandler {
                     //however there's no other way to have the proper line marked as beginning of a section (as the event comes first)
                     //without this, the last line of previous output would be marked as beginning of the fold.
                     if (addMojoFold && line.startsWith("[INFO] ---")) {     //NOI18N
-                        currentTreeNode.startFold(inputOutput);
+                        foldsBroken |= currentTreeNode.startFold(inputOutput);
                         addMojoFold = false;
                     }
                     if (addProjectFold && line.startsWith("[INFO] Building")) {
-                        currentTreeNode.startFold(inputOutput);
+                        foldsBroken |= currentTreeNode.startFold(inputOutput);
                         addProjectFold = false;
                     }
                     line = nextLine != null ? nextLine : readLine();
@@ -545,6 +546,9 @@ public class CommandLineOutputHandler extends AbstractOutputHandler {
     }
 
     private void trimTree(ExecutionEventObject obj) {
+        if (foldsBroken) {
+            return;
+        }
         ExecutionEventObject start = currentTreeNode.getStartEvent();
         while (!matchingEvents(obj.type, start.type)) { //#229877
             ExecutionEventObject innerEnd = createEndForStart(start);
diff --git a/java/maven/src/org/netbeans/modules/maven/execute/cmd/ExecutionEventObject.java b/java/maven/src/org/netbeans/modules/maven/execute/cmd/ExecutionEventObject.java
index 06f23c7faf..8b4cf061d4 100644
--- a/java/maven/src/org/netbeans/modules/maven/execute/cmd/ExecutionEventObject.java
+++ b/java/maven/src/org/netbeans/modules/maven/execute/cmd/ExecutionEventObject.java
@@ -165,30 +165,36 @@ public class ExecutionEventObject {
          * Start fold for the curent tree.
          *
          * @param io InputOutput the output is written to.
+         * @return true if the fold system is too broken to use
          */
-        public void startFold(InputOutput io) {
+        public boolean startFold(InputOutput io) {
             if (!IOFolding.isSupported(io)) {
-                return;
+                return false;
             }
 
             assert foldHandle == null;
             ExecutionEventObject.Tree parentProject = findParentNodeOfType(ExecutionEvent.Type.MojoStarted);
             if (parentProject != null) {
                 //in forked environment..
-                assert parentProject.foldHandle != null;
+                if (parentProject.foldHandle == null) {
+                    return true;
+                }
                 this.foldHandle = parentProject.foldHandle.silentStartFold(true);
-                return;
+                return false;
             }
 
             parentProject = findParentNodeOfType(ExecutionEvent.Type.ProjectStarted);
             if (parentProject == null) {
                 this.foldHandle = IOFolding.startFold(io, true);
+                return false;
             } else {
+                boolean broken = false;
                 if (parentProject.foldHandle == null) {
-                    parentProject.startFold(io);
+                    broken = parentProject.startFold(io);
                 }
                 assert parentProject.foldHandle != null;
                 this.foldHandle = parentProject.foldHandle.silentStartFold(true);
+                return broken;
             }
         }
 


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

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