LinShunKang commented on PR #12685:
URL: https://github.com/apache/kafka/pull/12685#issuecomment-1929526582

   > @LinShunKang , sorry for being late. I had a quick look at #14617, it 
looks like the `ByteBufferSerializer#serialize` is a public API and cannot be 
changed without KIP. You know more than I do, so, in your opinion, what should 
we do from now? Could we not touch the `ByteBufferSerializer#serialize` and 
only implement `ByteBufferSerializer#serializeToByteBuffer`? Do you think we 
should include people in this [PR](https://github.com/apache/kafka/pull/14617) 
to this PR for discussion? Or do you have any other thoughts?
   
   We could not only implement `ByteBufferSerializer#serializeToByteBuffer` 
because if `Serializer` implements this method, then the `Serializer#serialize` 
will never be called. And `ByteBufferSerializer#serialize` has obvious logical 
problems.
   
   I believe we should address the logical issues in 
`ByteBufferSerializer#serialize`, but this will introduce breaking changes for 
existing users. And the `Serializer` should not have both `serialize` and 
`serializeToByteBuffer` methods at the same time. Therefore, I suggest we 
tackle these issues in Kafka 4.0, where we can modify the signature of the 
`Serializer`:
   from 
   ```
   //before 4.0
   public interface Serializer<T> {
   
       byte[] serialize(String topic, T data);
   
       default byte[] serialize(String topic, Headers headers, T data) {
           return serialize(topic, data);
       }
   }
   ```
   to
   ```
   //since 4.0
   public interface Serializer<T> {
   
       ByteBuffer serialize(String topic, T data);
   
       ByteBuffer serialize(String topic, Headers headers, T data);
   }
   ```
   
   Then we could announce that we are modified the signature of the 
`Serializer` for existing users.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to