-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[KAFKA-6923] Refactoring Serializer/Deserializer #5494
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
Changes from 3 commits
68b7f8a
9ec62c2
6b632a6
4ca3d32
c820ad8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |
| */ | ||
| package org.apache.kafka.common.serialization; | ||
|
|
||
| import org.apache.kafka.common.header.Headers; | ||
|
|
||
| import java.io.Closeable; | ||
| import java.util.Map; | ||
|
|
||
|
|
@@ -43,7 +45,20 @@ public interface Deserializer<T> extends Closeable { | |
| * @param data serialized bytes; may be null; implementations are recommended to handle null by returning a value or null rather than throwing an exception. | ||
| * @return deserialized typed data; may be null | ||
| */ | ||
| T deserialize(String topic, byte[] data); | ||
| default T deserialize(String topic, byte[] data) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hey @viktorsomogyi , Sorry I missed the KIP discussion, but I just read the KIP over and didn't see a explanation of this: Can you explain the reason to provide a default implementation of this method? Thanks,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I just now saw the discussion in the vote thread. It sounds like you're going to remove this default. Sorry about that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Thank you for the review though. :) |
||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Deserialize a record value from a byte array into a value or object. | ||
| * @param topic topic associated with the data | ||
| * @param headers headers associated with the record; may be empty. | ||
| * @param data serialized bytes; may be null; implementations are recommended to handle null by returning a value or null rather than throwing an exception. | ||
| * @return deserialized typed data; may be null | ||
| */ | ||
| default T deserialize(String topic, Headers headers, byte[] data) { | ||
| return deserialize(topic, data); | ||
| } | ||
|
|
||
| @Override | ||
| void close(); | ||
|
|
||
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 may have been left behind from a previous iteration, but shouldn't we just rely on the default implementation?
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.
Indeed, I'll correct it.