Skip to content
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

Error Prone InvocationHandlerDelegation to ensure proxies handle delegate exceptions. #1032

Merged
merged 6 commits into from
Nov 11, 2019

Conversation

carterkozak
Copy link
Contributor

==COMMIT_MSG==
InvocationHandlers which delegate to another object must catch and unwrap
InvocationTargetException, otherwise an UndeclaredThrowableException will be thrown
each time the delegate throws an exception.
==COMMIT_MSG==

@changelog-app
Copy link

changelog-app bot commented Nov 7, 2019

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

InvocationHandlers which delegate to another object must catch and unwrap
InvocationTargetException, otherwise an UndeclaredThrowableException will be thrown
each time the delegate throws an exception.

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from j-baker November 7, 2019 19:36
@carterkozak
Copy link
Contributor Author

I'll report back here once I've verified this on a large internal repo.

@carterkozak
Copy link
Contributor Author

This doesn't handle the cases:

try {
  return method.invoke(delegate, args);
} catch (Throwable t) {
   //either
  handle(t);
  //or
  if (t instanceof InvocationTargetException) {
    throw t.getCause();
  }
  throw t;
}

Though they're unnecessarily difficult to read, I don't want to cause friction for implementations that aren't actually broken.

…gate exceptions.

InvocationHandlers which delegate to another object must catch and unwrap
InvocationTargetException, otherwise an UndeclaredThrowableException will be thrown
each time the delegate throws an exception.
@carterkozak carterkozak force-pushed the ckozak/InvocationHandlerDelegation branch from b43fc02 to 508121d Compare November 8, 2019 16:57
@carterkozak
Copy link
Contributor Author

carterkozak commented Nov 8, 2019

Verified in a large internal project (where it discovered four instances of the bug)

@bulldozer-bot bulldozer-bot bot merged commit 4340e31 into develop Nov 11, 2019
@bulldozer-bot bulldozer-bot bot deleted the ckozak/InvocationHandlerDelegation branch November 11, 2019 16:10
@svc-autorelease
Copy link
Collaborator

Released 2.30.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants