Copilot commented on code in PR #3645:
URL: https://github.com/apache/maven-surefire/pull/3645#discussion_r4731282053


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java:
##########
@@ -590,7 +590,7 @@ private static void getTestProblems(
             //noinspection ThrowableResultOfMethodCallIgnored
             SafeThrowable t = report.getStackTraceWriter().getThrowable();
             if (t != null) {
-                if (t.getMessage() != null) {
+                if (t.getLocalizedMessage() != null) {
                     int delimiter = stackTrace.indexOf(":");
                     String type = delimiter == -1 ? stackTrace : 
stackTrace.substring(0, delimiter);

Review Comment:
   For nonforked, untrimmed reports, this change corrupts `type` when 
`getMessage()` is null, `getLocalizedMessage()` is non-null, and an overridden 
`toString()` returns only the class name. The colon search reaches a frame such 
as `Test.java:42`, so the XML type includes stack frames. Restrict delimiter 
lookup to the first trace line and add a regression test for this override.



##########
surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java:
##########
@@ -202,27 +204,44 @@ private static boolean 
containsClassName(StackTraceElement[] stackTrace, StackTr
         return false;
     }
 
-    private static String causeToString(Throwable cause, StackTraceFilter 
filter) {
+    private static String causeToString(Throwable topmost, StackTraceFilter 
filter) {
         StringBuilder resp = new StringBuilder();
-        while (cause != null) {
+        Set<Throwable> seen = newIdentitySet();
+        seen.add(topmost);
+        for (Throwable cause = topmost.getCause(); cause != null && 
seen.add(cause); cause = cause.getCause()) {

Review Comment:
   When only a nested cause contains the requested class, an `outer → focused → 
outer` cycle prints `outer` both as the trace header and as its own `Caused by` 
entry. Pass the original exception into cause rendering and mark the path from 
it through the focused exception as already seen. Add a regression case where 
the focus is nested inside the cycle.



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

Reply via email to