-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Failing to handle deserialization exceptions in batch listener #3114
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
Comments
@ikercrg, You are right in that when you consume as
However, it appears that there is a bug that might be preventing us from using the method
If you create a standard |
Fixes: spring-projects#3114 * Since DeserializationExceptionHeader is currently porpagated as a `byte[]`, it encounters some issues when processing the header especially in batch listeners. Fixing this by providing the deserialization header without `byte[]` conversion * Adding test to verify * Refactoring in SerializationTestUtils
Fixes: #3114 * Since DeserializationExceptionHeader is currently porpagated as a `byte[]`, it encounters some issues when processing the header especially in batch listeners. Fixing this by providing the deserialization header without `byte[]` conversion * Adding test to verify * Refactoring in SerializationTestUtils **Auto-cherry-pick to `3.1.x` & `3.0.x`**
Fixes: #3114 * Since DeserializationExceptionHeader is currently porpagated as a `byte[]`, it encounters some issues when processing the header especially in batch listeners. Fixing this by providing the deserialization header without `byte[]` conversion * Adding test to verify * Refactoring in SerializationTestUtils (cherry picked from commit 7cc7fc8)
Fixes: #3114 * Since DeserializationExceptionHeader is currently porpagated as a `byte[]`, it encounters some issues when processing the header especially in batch listeners. Fixing this by providing the deserialization header without `byte[]` conversion * Adding test to verify * Refactoring in SerializationTestUtils (cherry picked from commit 7cc7fc8) # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/support/KafkaUtils.java
I am migrating Spring boot from version 2 to version 3.
In my former implementation, I was based on v2.8.4 documentation and all was working fine.
Currently, ListenerUtils.byteArrayToDeserializationException is removed and I have to use SerializationUtils.byteArrayToDeserializationException.
For this, I am basing on v3.1.x documentation, but I have problems.
The example given in the documentation, precisely this part, does not compile:
Theoretically what is passed is a byte[], but the method only admits a Header. So we would need a cast for that. With ListenerUtils I was casting it to byte[]. But now, I cast to Header or RecordHeader, I get the following error -> Foreign deserialization exception header ignored; possible attack? Something like the following:
I have tried to create a DeserializationExceptionHeader, but it is package-protected.
Using
List<ConsumerRecord<String, my_object>> my_method()
instead of what is said in the documentation
List<Thing> in, @Header(KafkaHeaders.BATCH_CONVERTED_HEADERS) List<Map<String, Object>> headers
works fine.
Issue opened as petition from @artembilan in Stackoverflow:
See https://stackoverflow.com/questions/78122348/failing-to-handle-deserialization-exceptions-in-batch-listener
The text was updated successfully, but these errors were encountered: