From c6a194dcf933dd7a4e2bf6b92bcb417957aba765 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 10 Feb 2015 22:23:12 -0500 Subject: ignore harmless exceptions I can't fix fyi, it's really hard to test this fix because the exception is not generally reproducable --- src/cuchaz/enigma/ExceptionIgnorer.java | 24 ++++++++++++++++++++++++ src/cuchaz/enigma/gui/Gui.java | 9 ++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/cuchaz/enigma/ExceptionIgnorer.java diff --git a/src/cuchaz/enigma/ExceptionIgnorer.java b/src/cuchaz/enigma/ExceptionIgnorer.java new file mode 100644 index 0000000..37c67da --- /dev/null +++ b/src/cuchaz/enigma/ExceptionIgnorer.java @@ -0,0 +1,24 @@ +package cuchaz.enigma; + +public class ExceptionIgnorer { + + public static boolean shouldIgnore(Throwable t) { + + // is this that pesky concurrent access bug in the highlight painter system? + // (ancient ui code is ancient) + if (t instanceof ArrayIndexOutOfBoundsException) { + StackTraceElement[] stackTrace = t.getStackTrace(); + if (stackTrace.length > 1) { + + // does this stack frame match javax.swing.text.DefaultHighlighter.paint() ? + StackTraceElement frame = stackTrace[1]; + if (frame.getClassName().equals("javax.swing.text.DefaultHighlighter") && frame.getMethodName().equals("paint")) { + return true; + } + } + } + + return false; + } + +} diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index 187ef5b..00cff59 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java @@ -70,6 +70,7 @@ import jsyntaxpane.DefaultSyntaxKit; import com.google.common.collect.Lists; import cuchaz.enigma.Constants; +import cuchaz.enigma.ExceptionIgnorer; import cuchaz.enigma.analysis.BehaviorReferenceTreeNode; import cuchaz.enigma.analysis.ClassImplementationsTreeNode; import cuchaz.enigma.analysis.ClassInheritanceTreeNode; @@ -147,9 +148,11 @@ public class Gui { CrashDialog.init(m_frame); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override - public void uncaughtException(Thread thread, Throwable ex) { - ex.printStackTrace(System.err); - CrashDialog.show(ex); + public void uncaughtException(Thread thread, Throwable t) { + t.printStackTrace(System.err); + if (!ExceptionIgnorer.shouldIgnore(t)) { + CrashDialog.show(t); + } } }); } -- cgit v1.2.3