Skip to content
Browse files

Need to unwrap exception before checking for security exception

  • Loading branch information...
1 parent 2390d3b commit 7e16cfa208d48ef5d0dfb87c67520aed4c93f6d2 @ratnikov committed Jun 13, 2013
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/org/jruby/util/log/LoggerFactory.java
View
15 src/org/jruby/util/log/LoggerFactory.java
@@ -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);
}
}
}

0 comments on commit 7e16cfa

Please sign in to comment.
Something went wrong with that request. Please try again.