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

smiklosovic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9142d0c851 Fix ExceptionsTable when stacktrace has zero elements
9142d0c851 is described below

commit 9142d0c8519944e02b3d449b21c3b42ab80caeb6
Author: Stefan Miklosovic <[email protected]>
AuthorDate: Thu Oct 30 12:30:00 2025 +0100

    Fix ExceptionsTable when stacktrace has zero elements
    
    patch by Stefan Miklosovic; reviewed by Brandon Williams, Dmitry 
Konstantinov for CASSANDRA-20992
---
 CHANGES.txt                                        |  1 +
 .../cassandra/db/virtual/ExceptionsTable.java      |  4 +--
 .../cassandra/db/virtual/ExceptionsTableTest.java  | 30 ++++++++++++++++++++++
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index f663072aa1..c1e0eebd2c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 5.1
+ * Fix ExceptionsTable when stacktrace has zero elements (CASSANDRA-20992)
  * Replace blocking wait with non-blocking delay in paxos repair 
(CASSANDRA-20983)
  * Implementation of CEP-55 - Generation of role names (CASSANDRA-20897)
  * Add cqlsh autocompletion for the identity mapping feature (CASSANDRA-20021)
diff --git a/src/java/org/apache/cassandra/db/virtual/ExceptionsTable.java 
b/src/java/org/apache/cassandra/db/virtual/ExceptionsTable.java
index 445aa49da6..e3055c4c2e 100644
--- a/src/java/org/apache/cassandra/db/virtual/ExceptionsTable.java
+++ b/src/java/org/apache/cassandra/db/virtual/ExceptionsTable.java
@@ -171,7 +171,7 @@ public class ExceptionsTable extends 
AbstractMutableVirtualTable
         if (INSTANCE != null)
         {
             INSTANCE.add(toPersist.getClass().getName(),
-                         stackTrace.get(0),
+                         stackTrace.isEmpty() ? "unknown" : stackTrace.get(0),
                          toPersist.getMessage(),
                          stackTrace,
                          now);
@@ -179,7 +179,7 @@ public class ExceptionsTable extends 
AbstractMutableVirtualTable
         else
         {
             preInitialisationBuffer.add(new 
ExceptionRow(toPersist.getClass().getName(),
-                                                         stackTrace.get(0),
+                                                         stackTrace.isEmpty() 
? "unknown" : stackTrace.get(0),
                                                          0,
                                                          
toPersist.getMessage(),
                                                          stackTrace,
diff --git a/test/unit/org/apache/cassandra/db/virtual/ExceptionsTableTest.java 
b/test/unit/org/apache/cassandra/db/virtual/ExceptionsTableTest.java
index 3ce5c2f3a5..c9799e1a9f 100644
--- a/test/unit/org/apache/cassandra/db/virtual/ExceptionsTableTest.java
+++ b/test/unit/org/apache/cassandra/db/virtual/ExceptionsTableTest.java
@@ -264,6 +264,28 @@ public class ExceptionsTableTest extends CQLTester
         });
     }
 
+    @Test
+    public void testEmptyStacktrace()
+    {
+        doWithVTable(4, table ->
+        {
+            // register after treating exception, so it goes to 
pre-initialisation buffer first
+            VirtualKeyspaceRegistry.instance.register(new 
VirtualKeyspace(KS_NAME, ImmutableList.of(table)));
+            ExceptionsTable.INSTANCE = getVirtualTable(ExceptionsTable.class, 
KS_NAME, EXCEPTIONS_TABLE_NAME);
+
+            JVMStabilityInspector.uncaughtException(currentThread(), new 
MyUncaughtExceptionWithoutStacktrace("my exception"));
+
+            ExceptionsTable.BoundedMap buffer = table.buffer;
+            assertEquals(1, buffer.size());
+
+            LinkedHashMap<String, ExceptionRow> partition = 
buffer.get(MyUncaughtExceptionWithoutStacktrace.class.getName());
+            ExceptionRow clustering = partition.get("unknown");
+            assertNotNull(clustering);
+            assertEquals(1, clustering.count);
+            assertEquals("my exception", clustering.message);
+        });
+    }
+
     private List<UntypedResultSet.Row> rows(String query)
     {
         return execute(query).stream().collect(toList());
@@ -306,4 +328,12 @@ public class ExceptionsTableTest extends CQLTester
             super(message);
         }
     }
+
+    public static class MyUncaughtExceptionWithoutStacktrace extends Throwable
+    {
+        public MyUncaughtExceptionWithoutStacktrace(String message)
+        {
+            super(message, null, false, false);
+        }
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to