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

ForgivingExceptionHandler swallows Errors #710

Open
vkochnev opened this issue Nov 1, 2021 · 11 comments
Open

ForgivingExceptionHandler swallows Errors #710

vkochnev opened this issue Nov 1, 2021 · 11 comments

Comments

@vkochnev
Copy link

vkochnev commented Nov 1, 2021

Several methods defined in ExceptionHandler interface accept Throwable as one of arguments.
ForgivingExceptionHandler and DefaultExceptionHandler (which is used as a default ExceptionHandler implementation) as one of it's descendants effectively ignore any encountered Errors leaving application in abnormal state, which is strongly discouraged according to Error's description.
Maybe it would be more correct to re-throw catched Errors after ExceptionHandler tried to log them or catch clauses should not even rely on ExceptionHandler to re-throw Errors.

@michaelklishin
Copy link
Member

It would be a significant breaking change. You can always use any ExceptionHandler implementation you care to develop.

@vkochnev
Copy link
Author

vkochnev commented Nov 1, 2021

Sorry, but I honestly cannot imagine situation when anyone would rely on Errors to be ignored. Exceptions yes totally, but not Errors.

@vkochnev
Copy link
Author

vkochnev commented Nov 1, 2021

Consider similar discussion on spring-amqp spring-projects/spring-amqp#1258

@acogoluegnes
Copy link
Contributor

We could add a JavaErrorHandler to the existing ExceptionHandler implementations. The question is what to do in the default implementation of this "sub-handler".

We can System.exit(int) in the default implementation for the next major release (6.0) and just have a pass-through in the 5.x.

Or we can do the System.exit(int) in the current major release. This is what Spring AMQP did. Any feedback on this change @garyrussell @artembilan?

@garyrussell
Copy link
Contributor

This is what Spring AMQP did.

Actually, we did the former; a second commit for that issue changed it to a no-op in 2.2.x

-       private OOMHandler oOMHandler = error -> System.exit(99);
+       private JavaLangErrorHandler javaLangErrorHandler = error -> { };

https://github.com/spring-projects/spring-amqp/blob/c96418f0f60659d9589ebfd45b44529958557f3e/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java#L249

and exit the jvm in the next release 2.3.0

https://github.com/spring-projects/spring-amqp/blob/447a6964a971e6922dedf467927a6d0664de1635/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java#L251

@acogoluegnes
Copy link
Contributor

OK, thanks @garyrussell. So you chose to introduce the breaking change between 2.2 and 2.3. Is this something you usually do between minor versions?

@garyrussell
Copy link
Contributor

Yes, if the problem is serious enough. At this stage of the project's maturity, major versions are far apart.

@acogoluegnes
Copy link
Contributor

OK, thanks for the feedback @garyrussell. WDYT @michaelklishin?

@michaelklishin
Copy link
Member

@acogoluegnes we can do the same thing and even bump major version. I wouldn't mind that.

@acogoluegnes
Copy link
Contributor

I'd like to include several changes in 6.0 (#418, #432, #608), and even why not deprecate ConnectionFactory in favor of what comes out of #608, so it's a bit of work.

We can add a JavaErrorHandler to the existing exception handlers and make it a no-op for 5.x and System.exit(int) for 6.0.

@vkochnev
Copy link
Author

vkochnev commented Nov 5, 2021

I've done some search around the repo and discovered a few more suspicious Throwable catches also ignoring Errors




Would it be more appropriate to file them separately and link all together?

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

No branches or pull requests

4 participants