Skip to content

Need to unwrap exception before checking for security exception #816

Merged
merged 1 commit into from Jun 22, 2013
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);
}
}
}
Something went wrong with that request. Please try again.