-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Data in handle method is @Nullable #1837
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.
Please, fix Checkstyle issue:
Error: eckstyle] [ERROR] /home/runner/work/spring-kafka/spring-kafka/spring-kafka/src/main/java/org/springframework/kafka/listener/BatchLoggingErrorHandler.java:26:1: Extra separation in import group before 'org.springframework.lang.Nullable' [ImportOrder]
You can check it locally with Gradle check
task.
Thanks
@artembilan Hi, fixed right away. Sorry for inconvienience. |
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.
I'm OK with this change: doesn't look like it breaks something.
Although I have doubts if we should propagate something reasonable in those default methods instead of null
.
Let's see what @garyrussell thinks on the matter!
@kkocel Under what circumstances are you seeing it being called with Even with consumer exceptions (before we receive any Lines 1597 to 1605 in e624891
This is misleading... spring-kafka/spring-kafka/src/main/java/org/springframework/kafka/listener/ErrorHandler.java Lines 39 to 41 in e624891
All error handlers provided by the framework implement this method so it is never called. |
If you implement import org.apache.kafka.clients.consumer.ConsumerRecord
import org.springframework.kafka.listener.ErrorHandler
import java.lang.Exception
class MyErrorHandler : ErrorHandler {
override fun handle(thrownException: Exception, data: ConsumerRecord<*, *>) {
TODO("Not yet implemented")
}
} parameter |
@garyrussell having proper annotations is crucial for having proper types in Kotlin, as you can run into a problem @delor stated. More info here: https://www.youtube.com/watch?v=DvqXdnzhlSc&t=622s |
Thank you for the patience, @kkocel, and info! May you share with us a stack trace for this issue to have a whole picture? Nevertheless I still think that we may revise those |
I fully understand that. I believe we should deprecate that method; users should always implement Making it |
Sorry, can't provide a stacktrace as we have moved on with different approach and can't recreate it. |
I have tried several different ways to fix this in a non-breaking way without success, so I think I will go ahead and merge this; thanks for the contribution. I have re-opened this issue #615 so we can rework this error handler hierarchy in a breaking way in 3.0. |
Motivation - Kotlin uses jsr305 annotations to deduct non-null / nullable types. This PR marks data as explicitly nullable (which happen in code).
Without this it's impossible to pass null value as
data
parameter in Kotlin.