Skip to content

Unwrap InvocationTargetException from underlying statement execution#744

Merged
markt-asf merged 1 commit into
apache:mainfrom
mc1arke:69255
Aug 9, 2024
Merged

Unwrap InvocationTargetException from underlying statement execution#744
markt-asf merged 1 commit into
apache:mainfrom
mc1arke:69255

Conversation

@mc1arke
Copy link
Copy Markdown
Member

@mc1arke mc1arke commented Aug 8, 2024

When executing a wrapped statement, any resulting SQLException is wrapped in an InvocationTargetException by the reflective invocation, which is rethrown by the InvocationHandler as an
UndeclaredThrowableException. To ensure the expected SQLException is thrown, the invocation of the wrapped object is being moved into the existing try-catch block, thereby ensuring the InvocationTargetException is unwrapped and the underlying exception thrown by the handler.

https://bz.apache.org/bugzilla/show_bug.cgi?id=69255

When executing a wrapped statement, any resulting SQLException is
wrapped in an InvocationTargetException by the reflective invocation,
which is rethrown by the InvocationHandler as an
UndeclaredThrowableException. To ensure the expected SQLException is
thrown, the invocation of the wrapped object is being moved into the
existing try-catch block, thereby ensuring the InvocationTargetException
is unwrapped and the underlying exception thrown by the handler.
@markt-asf markt-asf merged commit 2953661 into apache:main Aug 9, 2024
@VRBogdanov
Copy link
Copy Markdown

Hello @markt-asf, is there any possible chance of having pre-release snapshot with this change to validate it or we should wait for official build ?

@markt-asf
Copy link
Copy Markdown
Contributor

There will be one in the snapshot repo in about 40 mins once the CI system finishes testing it. (There is a snapshot build after ~every commit).

@markt-asf
Copy link
Copy Markdown
Contributor

It isn't an official release. It is for testing purposes only. Use it at your own risk. If your server catches fire don't blame us ;)

@VRBogdanov
Copy link
Copy Markdown

Of course, thanks a lot!

@thraciatron
Copy link
Copy Markdown

I just wanted to point out that we had a similar issue to VRBogdanov where upgrading to 9.0.93 from 9.0.91, starting throwing java.lang.reflect.UndeclaredThrowableException on application start-up.

Upgrading to the 9.0.94-dev (Snapshot) release confirmed that the changes here fixed the issue. So we will wait for 9.0.94 to be released before upgrading. Thanks all.

@mc1arke mc1arke deleted the 69255 branch August 13, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants