-
Notifications
You must be signed in to change notification settings - Fork 1.7k
catch exceptions thrown from container error handler #595
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
Conversation
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.
Good catch, indeed!
Can we have some test-case though to cover this situation?
Also, be sure to run gradlew check
to see the Checkstyle violations.
Thanks
@artembilan Sorry for checkstyle violations. And i have rethought these questions.
|
Thank you for the update @realcbb ! I can't say anything (yet) about your suggestions, but that definitely looks like a separate issue. Anyway such a decision I deffer to @garyrussell |
I didn't supplement the test-cases yet because of the suggestion 1 I mentioned in the previous comment.
We have many error handlers now, For suggestion 2 I mentioned in the previous comment, it's another question. Maybe I should open a new issue to talk about that. |
Yeah... You know if your first suggestion is going to be behavior change and that is not what we can allow ourselves to do in the point release: we just can't introduce some breaking change here even if it sounds reasonable. The next minor version is a good place to reconsider these refactorings. Right now I would just concentrate on the bug fix and raise appropriate issues for the next version. Therefore we need a test-case to cover what you explain in the PR header. That's all. Thanks for understanding. |
update master
@artembilan |
I updated and committed it again. But it said that there are still conflicts. |
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.
To solve collisions you have to rebase
your fix-1
branch against the latest upstream master
:
git checkout master
git pull upstream master
git checkout -
git rebase master
git push origin fix-1 -f
@artembilan Thanks! Please check it. |
Thank you! Looking forward for more! |
if (containerErrorHandler != null) { | ||
if (containerErrorHandler instanceof ConsumerAwareErrorHandler | ||
|| containerErrorHandler instanceof ConsumerAwareBatchErrorHandler) { | ||
containerErrorHandler.handle(e, null, this.consumer); |
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.
This is a problem here; I noticed this while running tests...
java.lang.UnsupportedOperationException: Container should never call this
at org.springframework.kafka.listener.RemainingRecordsErrorHandler.handle(RemainingRecordsErrorHandler.java:39)
at org.springframework.kafka.listener.SeekToCurrentErrorHandler.handle(SeekToCurrentErrorHandler.java:1)
at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:752)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
testExceptionWhenCommitAfterRebalance
Fixes spring-projects#614 PR spring-projects#595 added support for calling error handlers for general errors not related to listener invocation. However, the wrong `handle()` method was called. Add a default implementation of the lowest interface method in the hierarchies to `ErrorHandler` and `BatchErrorHandler` respectively and invoke that so the right method will always be invoked, regardless of the error handler type. Also see spring-projects#615
Fixes spring-projects#614 PR spring-projects#595 added support for calling error handlers for general errors not related to listener invocation. However, the wrong `handle()` method was called. Add a default implementation of the lowest interface method in the hierarchies to `ErrorHandler` and `BatchErrorHandler` respectively and invoke that so the right method will always be invoked, regardless of the error handler type. Also see spring-projects#615
Fixes spring-projects#614 PR spring-projects#595 added support for calling error handlers for general errors not related to listener invocation. However, the wrong `handle()` method was called. Add a default implementation of the lowest interface method in the hierarchies to `ErrorHandler` and `BatchErrorHandler` respectively and invoke that so the right method will always be invoked, regardless of the error handler type. Also see spring-projects#615
Fixes spring-projects#614 PR spring-projects#595 added support for calling error handlers for general errors not related to listener invocation. However, the wrong `handle()` method was called. Add a default implementation of the lowest interface method in the hierarchies to `ErrorHandler` and `BatchErrorHandler` respectively and invoke that so the right method will always be invoked, regardless of the error handler type. Also see spring-projects#615
Fixes #614 PR #595 added support for calling error handlers for general errors not related to listener invocation. However, the wrong `handle()` method was called. Add a default implementation of the lowest interface method in the hierarchies to `ErrorHandler` and `BatchErrorHandler` respectively and invoke that so the right method will always be invoked, regardless of the error handler type. Also see #615
In situations like committing acks while consumer group has already rebalanced, and the container error handler is instance of
ConsumerAwareErrorHandler
orConsumerAwareBatchErrorHandler
, the error handler will throw an exception which would not be caught. Then the consumer will be dead, it can not receive messages any more.