mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
GP-3145 - Squash some known unfixable exceptions ecountered when using
the Help Window
This commit is contained in:
parent
8e3aaf0304
commit
3606b3364d
@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@ -22,6 +22,7 @@ import java.rmi.ConnectException;
|
|||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
import ghidra.util.SystemUtilities;
|
import ghidra.util.SystemUtilities;
|
||||||
import ghidra.util.exception.ClosedException;
|
import ghidra.util.exception.ClosedException;
|
||||||
|
import utilities.util.reflection.ReflectionUtilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to handle exceptions caught within the Swing event dispatch thread.
|
* Class to handle exceptions caught within the Swing event dispatch thread.
|
||||||
@ -52,15 +53,7 @@ public class SwingExceptionHandler implements UncaughtExceptionHandler {
|
|||||||
t = t.getCause();
|
t = t.getCause();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t instanceof ThreadDeath) {
|
if (shouldIgnore(t)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t instanceof ConnectException) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t instanceof ClosedException) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +74,58 @@ public class SwingExceptionHandler implements UncaughtExceptionHandler {
|
|||||||
t);
|
t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean shouldIgnore(Throwable t) {
|
||||||
|
|
||||||
|
if (t instanceof ThreadDeath) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t instanceof ConnectException) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t instanceof ClosedException) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isKnownJavaHelpException(t)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isKnownJavaHelpException(Throwable t) {
|
||||||
|
|
||||||
|
String stackString = ReflectionUtilities.stackTraceToString(t);
|
||||||
|
if (stackString.contains("com.sun.java.help.impl.JHelpPrintHandler$JHFrame.validate")) {
|
||||||
|
// This happens in the Java Help API when trying to print. We do not have license to
|
||||||
|
// change that code, so squash the exception here. Printing still seems to work as
|
||||||
|
// expected.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// There is an exception(s) that happens if the user has shown the Help Window and then
|
||||||
|
// switches themes. This exception is harder to test for, since it has not stack elements
|
||||||
|
// specific to the help API. Below are some (hopefully) help-specific stack elements that
|
||||||
|
// we can use to filter out this exception(s).
|
||||||
|
//
|
||||||
|
if (stackString.contains("javax.help.plaf.basic.BasicTOCNavigatorUI")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stackString.contains("javax.swing.text.html.BlockView") &&
|
||||||
|
stackString.contains("javax.swing.text.html.HTMLDocument.fireChangedUpdate")) {
|
||||||
|
// Log a message since this type of exception may happen outside of the help system. It
|
||||||
|
// may help developers to see this in the console.
|
||||||
|
Msg.debug(SwingExceptionHandler.class, "Squashed an assumed help exception");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
handleUncaughtException(e);
|
handleUncaughtException(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user