Skip to content

Conversation

@vvcephei
Copy link
Contributor

@vvcephei vvcephei commented Sep 7, 2018

Currently, scala.Serdes.String, for example, invokes Serdes.String() once and caches the result.

However, the implementation of the String serde has a non-empty configure method that is variant in whether it's used as a key or value serde. So we won't get correct execution if we create one serde and use it for both keys and values.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@vvcephei
Copy link
Contributor Author

vvcephei commented Sep 7, 2018

@mjsax @bbejeck @joan38 , Do you mind reviewing this?

This is a source-compatible change.

Copy link
Member

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @vvcephei LGTM

@mjsax mjsax requested a review from guozhangwang September 7, 2018 18:53
@mjsax mjsax added the streams label Sep 7, 2018
@joan38
Copy link
Contributor

joan38 commented Sep 11, 2018

Mutablility...
Thanks @vvcephei, all good to me.

@vvcephei
Copy link
Contributor Author

@joan38 , Yeah, sort of... What's actually going on is more like dependency injection. The class is being configured after creation and then cached.

But, yes, this can be (and has been) a source of bugs.

@vvcephei
Copy link
Contributor Author

Ok, @guozhangwang , I think this is good to go.

@guozhangwang
Copy link
Contributor

LGTM!

@guozhangwang guozhangwang merged commit 9dac615 into apache:trunk Sep 11, 2018
guozhangwang pushed a commit that referenced this pull request Sep 11, 2018
Currently, scala.Serdes.String, for example, invokes Serdes.String() once and caches the result.

However, the implementation of the String serde has a non-empty configure method that is variant in whether it's used as a key or value serde. So we won't get correct execution if we create one serde and use it for both keys and values.

Reviewers: Bill Bejeck <bill@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
@guozhangwang
Copy link
Contributor

Cherry-picked to 2.0 as well.

@vvcephei
Copy link
Contributor Author

Thanks @guozhangwang

@ijuma
Copy link
Member

ijuma commented Sep 13, 2018

This is definitely mutability and makes the implicit usage quite suspect. Unfortunate. :(

pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
Currently, scala.Serdes.String, for example, invokes Serdes.String() once and caches the result.

However, the implementation of the String serde has a non-empty configure method that is variant in whether it's used as a key or value serde. So we won't get correct execution if we create one serde and use it for both keys and values.

Reviewers: Bill Bejeck <bill@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants