Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Need to unwrap exception before checking for security exception #816

Merged
merged 1 commit into from

2 participants

@ratnikov

As is the instanceof SecurityException is useless since reflection invocation will likely be wrapped in InvocationTargetException

@headius
Owner

Looks good to me. Merging.

@headius headius merged commit 5031dca into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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);
}
}
}
Something went wrong with that request. Please try again.