dcapwell commented on code in PR #2104:
URL: https://github.com/apache/cassandra/pull/2104#discussion_r1132709032


##########
src/java/org/apache/cassandra/streaming/StreamSession.java:
##########
@@ -1340,32 +1338,41 @@ public String toString()
                '}';
     }
 
-    public static Throwable boundStackTrace(Throwable e, int limit)
+    public static StringBuilder boundStackTrace(Throwable e, int limit)
     {
         Set<Throwable> visited = Collections.newSetFromMap(new 
IdentityHashMap<>());
-        return boundStackTrace(e, limit, visited);
+        StringBuilder out = new StringBuilder();
+        return boundStackTrace(e, limit, visited, out);
     }
 
-    public static Throwable boundStackTrace(Throwable e, int limit, 
Set<Throwable> visited)
+    public static StringBuilder boundStackTrace(Throwable e, int limit, 
Set<Throwable> visited, StringBuilder out)
     {
         if (e == null)
-            return e;
+            return null;
 
         if (!visited.add(e))
-            return e;
+            return out.append("[CIRCULAR REFERENCE: 
").append(e.getClass().getName()).append(": 
").append(e.getMessage()).append("]");
         visited.add(e);
 
         if (e.getStackTrace().length == 0 || e.getStackTrace().length < limit)
         {
-            boundStackTrace(e.getCause(), limit, visited);
-            return e;
+            out.append(e.getClass().getName()).append(": 
").append(e.getMessage()).append('\n');
+            boundStackTrace(e.getCause(), limit, visited, out);
+            return out;
         }
 
         StackTraceElement[] stackTrace = e.getStackTrace();
-        StackTraceElement[] limitedStackTrace = Arrays.copyOfRange(stackTrace, 
0, limit);
-        e.setStackTrace(limitedStackTrace);
-        boundStackTrace(e.getCause(), limit, visited);
+        StringBuilder stackTraceBuilder = new StringBuilder();

Review Comment:
   why are you creating a new `StringBuilder`, this is a bug... your test 
should have caught this if you did what we talked about and use the string it 
should be and not the return string.



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

Reply via email to