-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#41] Fail Gracefully when Debug Provider Invalid #42
base: sustaining/13.5.x
Are you sure you want to change the base?
[#41] Fail Gracefully when Debug Provider Invalid #42
Conversation
fd3e0fc
to
2078afa
Compare
- Ensure that debug provider fallback is in place BEFORE trying to log any exceptions about failing to initialize the debug provider. - Upgrade `openam-shared` to JDK 8+ (see below). - Clean-up debug provider initialization. - Switch to multi-catch instead of repetitive `catch` blocks (JDK 7+). - Pull-in `forgerock-guava-base` to allow us to use `Strings.isNullOrEmpty()`. - Switch to `Optional` to support chaining `trim()` on provider names without an explicit `null` check (JDK 8+). Closes WrenSecurity#41.
2078afa
to
842160c
Compare
try { | ||
provider = (IDebugProvider) Class.forName(providerName).newInstance(); | ||
} catch (ClassNotFoundException cnex) { | ||
provider = (IDebugProvider)Class.forName(providerName).newInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that this code was already here but isn't newInstance
considered evil? The docs say:
Note that this method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The Constructor.newInstance method avoids this problem by wrapping any exception thrown by the constructor in a (checked) InvocationTargetException.
provider = (IDebugProvider) Class.forName(providerName).newInstance(); | ||
} catch (ClassNotFoundException cnex) { | ||
provider = (IDebugProvider)Class.forName(providerName).newInstance(); | ||
} catch (ClassNotFoundException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a point in catching specific exceptions? Doesn't any exception mean the provider failed to load? How would we deal with newer Java version throwing other exceptions?
openam-shared
to JDK 8+ (see below).catch
blocks (JDK 7+).forgerock-guava-base
to allow us to useStrings.isNullOrEmpty()
.Optional
to support chainingtrim()
on provider names without an explicitnull
check (JDK 8+).Closes #41.