-
Notifications
You must be signed in to change notification settings - Fork 463
Introduce JDK 21 compilation support #2433
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,16 +70,25 @@ public static DataSource find(String dsName, Context context) { | |
|
|
||
| try { | ||
| Object dataSourceO = context.lookup(dsName); | ||
| if (dataSourceO != null && dataSourceO instanceof DataSource) { | ||
| return (DataSource) dataSourceO; | ||
| } else { | ||
| throw new SynapseCommonsException("DataSource : " + dsName + " not found " + | ||
| "when looking up using JNDI properties : " + context.getEnvironment(), log); | ||
| if (dataSourceO != null) { | ||
| // Let JNDI automatically dereference if needed | ||
| if (dataSourceO instanceof javax.naming.Reference) { | ||
| dataSourceO = javax.naming.spi.NamingManager.getObjectInstance( | ||
| dataSourceO, null, null, context.getEnvironment()); | ||
| } | ||
| if (dataSourceO instanceof DataSource) { | ||
| return (DataSource) dataSourceO; | ||
| } | ||
| } | ||
| throw new SynapseCommonsException("DataSource : " + dsName + " not found " + | ||
| "when looking up using JNDI properties : " + context.getEnvironment(), log); | ||
|
|
||
|
|
||
| } catch (NamingException e) { | ||
| throw new SynapseCommonsException("Error looking up DataSource : " + dsName | ||
| + " using JNDI" + " properties : " + context, e); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
Comment on lines
+90
to
92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve exception handling to preserve context. The generic 🔎 Proposed fix to improve exception handling } catch (NamingException e) {
throw new SynapseCommonsException("Error looking up DataSource : " + dsName
+ " using JNDI" + " properties : " + context, e);
} catch (Exception e) {
- throw new RuntimeException(e);
+ throw new SynapseCommonsException("Unexpected error resolving DataSource : "
+ + dsName + " from JNDI", e, log);
}
🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
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.
The JNDI datasource lookup logic now includes automatic dereferencing for javax.naming.Reference objects, but the catch block for the generic Exception is problematic. It wraps the exception in a RuntimeException without providing any context or logging. This could hide important debugging information. Consider either logging the exception before rethrowing it, or wrapping it in a SynapseCommonsException with an appropriate message, similar to the NamingException handler above it.