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


##########
test/distributed/org/apache/cassandra/distributed/test/streaming/BoundExceptionTest.java:
##########
@@ -34,38 +32,36 @@
     @Test
     public void testSingleException()
     {
-        Throwable boundedStackTrace = StreamSession.boundStackTrace(new 
RuntimeException("test exception"), LIMIT);
+        Throwable exceptionToTest = new RuntimeException("test exception");
+        StringBuilder boundedStackTrace = 
StreamSession.boundStackTrace(exceptionToTest, LIMIT);
 
         String expectedStackTrace = "java.lang.RuntimeException: test 
exception\n" +
-                                        "\tat 
org.apache.cassandra.distributed.test.streaming.BoundExceptionTest.testSingleException(BoundExceptionTest.java:37)\n"
 +
-                                        "\tat 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)\n";
+                                    
"\torg.apache.cassandra.distributed.test.streaming.BoundExceptionTest.testSingleException(BoundExceptionTest.java:35)\n"
 +
+                                    
"\tjava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)";
 
-        
assertEquals(expectedStackTrace,Throwables.getStackTraceAsString(boundedStackTrace));
-        assertEquals(boundedStackTrace.getStackTrace().length, LIMIT);
+        assertEquals(expectedStackTrace,boundedStackTrace.toString());
+        
assertEquals(boundedStackTrace.toString().split(System.lineSeparator()).length 
- 1, LIMIT);
     }
 
     @Test
     public void testNestedException()
     {
         Throwable exceptionToTest = new RuntimeException(new 
IllegalArgumentException("the disk /foo/var is bad", new IOException("Bad disk 
somewhere")));
-        Throwable boundedStackTrace = 
StreamSession.boundStackTrace(exceptionToTest, LIMIT);
+        StringBuilder boundedStackTrace = 
StreamSession.boundStackTrace(exceptionToTest, LIMIT);
 
         String expectedStackTrace1 = "java.lang.RuntimeException: 
java.lang.IllegalArgumentException: the disk /foo/var is bad\n" +
-                                    "\tat 
org.apache.cassandra.distributed.test.streaming.BoundExceptionTest.testNestedException(BoundExceptionTest.java:50)\n";
-        String expectedStackTrace2 = "java.lang.IllegalArgumentException: the 
disk /foo/var is bad\n";
-        String expectedStackTrace3 = "java.io.IOException: Bad disk 
somewhere\n";
-
-        String boundedStackTraceAsString = 
Throwables.getStackTraceAsString(boundedStackTrace);
-
-        assertTrue(boundedStackTraceAsString.contains(expectedStackTrace1));
-        assertTrue(boundedStackTraceAsString.contains(expectedStackTrace2));
-        assertTrue(boundedStackTraceAsString.contains(expectedStackTrace3));
-
-        while (boundedStackTrace != null)
-        {
-            assertEquals(boundedStackTrace.getStackTrace().length, LIMIT);
-            boundedStackTrace = boundedStackTrace.getCause();
-        }
+                                     
"\torg.apache.cassandra.distributed.test.streaming.BoundExceptionTest.testNestedException(BoundExceptionTest.java:49)\n"
 +
+                                     
"\tjava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)\n" +
+                                     "java.lang.IllegalArgumentException: the 
disk /foo/var is bad\n" +
+                                     
"\torg.apache.cassandra.distributed.test.streaming.BoundExceptionTest.testNestedException(BoundExceptionTest.java:49)\n"
 +
+                                     
"\tjava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)\n" +

Review Comment:
   left this comment in the code, why are we printing these elements?  middle 
causes normally don't offer much value outside of the type/msg



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