Need to unwrap exception before checking for security exception #816

Merged
merged 1 commit into from Jun 22, 2013
Jump to file or symbol
Failed to load files and symbols.
+12 −3
Diff settings

Always

Just for now

@@ -65,10 +65,19 @@ public static Logger getLogger(String loggerName) {
try {
Logger logger = (Logger) CTOR.newInstance(loggerName);
return logger;
- } catch (SecurityException e) {
- return new StandardErrorLogger(loggerName);
} catch (Exception e) {
- throw new IllegalStateException("unable to instantiate logger", e);
+ Throwable rootCause = e;
+
+ // Unwrap reflection exception wrappers
+ while (rootCause.getCause() != null) {
+ rootCause = rootCause.getCause();
+ }
+
+ if (rootCause instanceof SecurityException) {
+ return new StandardErrorLogger(loggerName);
+ }
+
+ throw new IllegalStateException("unable to instantiate logger", e);
}
}
}