netudima commented on code in PR #4356:
URL: https://github.com/apache/cassandra/pull/4356#discussion_r2348466413


##########
src/java/org/apache/cassandra/utils/JVMStabilityInspector.java:
##########
@@ -63,11 +66,52 @@ public final class JVMStabilityInspector
     // It is used for unit test
     public static OnKillHook killerHook;
 
-    private JVMStabilityInspector() {}
+    @VisibleForTesting
+    public static volatile ExceptionsTable exceptionsTable;
+
+    private JVMStabilityInspector()
+    {
+    }
 
     public static void uncaughtException(Thread thread, Throwable t)
     {
-        try { StorageMetrics.uncaughtExceptions.inc(); } catch (Throwable 
ignore) { /* might not be initialised */ }
+        try
+        {
+            StorageMetrics.uncaughtExceptions.inc();
+
+            if (exceptionsTable == null)
+                exceptionsTable = 
AbstractVirtualTableAppender.getVirtualTable(ExceptionsTable.class, 
EXCEPTIONS_TABLE_NAME);
+
+            Throwable toPersist = t;
+
+            while (toPersist.getCause() != null)
+                toPersist = toPersist.getCause();
+
+            List<String> stackTrace = 
ExceptionRow.extractStacktrace(toPersist.getStackTrace());
+            long now = Clock.Global.currentTimeMillis();
+
+            if (exceptionsTable != null)
+            {
+                exceptionsTable.add(toPersist.getClass().getName(),
+                                    stackTrace.get(0),
+                                    toPersist.getMessage(),
+                                    stackTrace,
+                                    now);
+            }
+            else
+            {
+                preInitialisationBuffer.add(new 
ExceptionRow(toPersist.getClass().getName(),
+                                                             stackTrace.get(0),
+                                                             0,
+                                                             
toPersist.getMessage(),
+                                                             stackTrace,
+                                                             now));
+            }

Review Comment:
   what's about moving/encapsulating of this logic into ExceptionsTable



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