You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "rmannibucau (via GitHub)" <gi...@apache.org> on 2026/09/17 21:18:59 UTC

[PR] Fixes #13135: ensure completeness of the reactor summary, privilege f… [maven]

rmannibucau opened a new pull request, #13173:
URL: https://github.com/apache/maven/pull/13173

   …ailures last
   
   Backport of the reactor summary improvements to the 3.10.x branch: every module is now always listed (including skipped ones) and failures are displayed last, logged at error level, so they are easier to spot.
   
   <!--
   Please open pull requests against one of the following branches:
   
   - master — default target for all changes (new features + bug fixes).  
     If the change should also go to maven-4.0.x, request a backport in the PR.
   
   - maven-3.10.x — target for 3.x changes (new features + bug fixes).  
     If the change should also go to maven-3.9.x, request a backport in the PR.
     maven-3.9.x should receive only serious bug fixes, as it is approaching EOL.
   
   Backports are typically handled by maintainers; 
   however, after agreement you may open a separate backport PR to the target maintenance branch.
   -->
   
   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
   - [ ] Your pull request should address just one issue, without pulling in other changes.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Each commit in the pull request should have a meaningful subject line and body.
     Note that commits might be squashed by a maintainer on merge.
   - [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
     This may not always be possible but is a best-practice.
   - [ ] Run `mvn verify` to make sure basic checks pass.
     A more thorough check will be performed on your pull request automatically.
   - [ ] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
   - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


-- 
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: issues-unsubscribe@maven.apache.org

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


Re: [PR] Fixes #13135: ensure completeness of the reactor summary, privilege f… [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #13173:
URL: https://github.com/apache/maven/pull/13173


-- 
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: issues-unsubscribe@maven.apache.org

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


Re: [PR] Fixes #13135: ensure completeness of the reactor summary, privilege f… [maven]

Posted by "gnodet-bot (via GitHub)" <gi...@apache.org>.
gnodet-bot commented on code in PR #13173:
URL: https://github.com/apache/maven/pull/13173#discussion_r4041555970


##########
maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java:
##########
@@ -213,16 +223,71 @@ private void logReactorSummary(MavenSession session) {
                 buffer.append(' ');
             }
 
-            buffer.append(statusMessage);
-            if (buildSummary != null) {
-                formatBuildTime(buffer, buildSummary);
+            buffer.append(entry.getStatusMessage());
+            if (entry.getBuildSummary() != null) {
+                formatBuildTime(buffer, entry.getBuildSummary());
             }
 
-            logger.info(buffer.toString());
+            if (entry.getBuildSummary() instanceof BuildFailure) {
+                logger.error(buffer.toString());
+            } else {
+                logger.info(buffer.toString());
+            }
+            buffer.setLength(0);
+        }
+    }
+
+    private static final class ReactorSummaryRequest {
+        private final List<ReactorSummaryEntry> entries;
+        private final StringBuilder buffer;
+        private final boolean singleVersion;
+
+        private ReactorSummaryRequest(List<ReactorSummaryEntry> entries, StringBuilder buffer, boolean singleVersion) {

Review Comment:
   🔧 **`ReactorSummaryRequest` carries mutable state — allocate `StringBuilder` locally instead**
   
   `ReactorSummaryRequest` is a private data-holder class but it carries a `StringBuilder` that is mutated across all three `logReactorSummaryGroup` calls (`append` + `setLength(0)`). This is a correctness trap: any future refactor that calls `logReactorSummaryGroup` in a different order, twice for the same group, or in parallel will silently corrupt the buffer with no compiler warning.
   
   The fix is trivial and has no checkstyle impact — allocate the `StringBuilder` locally at the top of `logReactorSummaryGroup` and drop it from the class:
   
   ```suggestion
           private final List<ReactorSummaryEntry> entries;
           private final boolean singleVersion;
   ```
   
   Then update the constructor accordingly, remove `getBuffer()`, change the call site to:
   ```java
   ReactorSummaryRequest request = new ReactorSummaryRequest(entries, isSingleVersion);
   ```
   And in `logReactorSummaryGroup`, replace `StringBuilder buffer = request.getBuffer();` with:
   ```java
   StringBuilder buffer = new StringBuilder(128);
   ```
   
   Note: the merged master implementation (`#13167`) already uses this pattern — the local `StringBuilder` approach. This 3.10.x backport should match.



##########
maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java:
##########
@@ -170,39 +171,48 @@ private void logReactorSummary(MavenSession session) {
         String failureMessage = builder().failure("FAILURE").build();
         String unknownMessage = builder().warning("UNKNOWN").build();
 
-        boolean lastWasSkipped = false;
+        List<ReactorSummaryEntry> entries = new ArrayList<>(projects.size());
         for (MavenProject project : projects) {
             BuildSummary buildSummary = result.getBuildSummary(project);
 
             String statusMessage;
-            boolean shouldSkip = result.hasExceptions();
-            if (buildSummary == null) {
-                statusMessage = skippedMessage;
-            } else if (buildSummary instanceof BuildSuccess) {
+            int group;
+            if (buildSummary instanceof BuildSuccess) {
                 statusMessage = successMessage;
+                group = 1;
             } else if (buildSummary instanceof BuildFailure) {
                 statusMessage = failureMessage;
-                shouldSkip = false;
+                group = 2;
+            } else if (buildSummary == null) {
+                statusMessage = skippedMessage;
+                group = 0;

Review Comment:
   ℹ️ **`UNKNOWN` buildSummary silently grouped with SKIPPED — consider `group = 2` for safety**
   
   `BuildSummary` is currently abstract with only `BuildSuccess` and `BuildFailure` as concrete subclasses, so this branch is dead code in practice. But if a third subclass (e.g. `BuildCancelled`) is ever added, the result will land in group 0 alongside SKIPPED modules and be logged at `info` level, with no visual distinction from a module that was never scheduled to run.
   
   Assigning `group = 2` makes this branch safe by default at zero cost:
   
   ```suggestion
                   statusMessage = unknownMessage;
                   group = 2;
   ```
   
   Same concern applies to the second `else` branch at line 191.



-- 
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: issues-unsubscribe@maven.apache.org

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