Skip to content

HOTFIX: Fix wrong setting of Serde in MeteredTimestampWindowStore#6808

Merged
bbejeck merged 2 commits into
apache:trunkfrom
cadonna:fix_valueSerde_in_MeteredWindowStore
May 28, 2019
Merged

HOTFIX: Fix wrong setting of Serde in MeteredTimestampWindowStore#6808
bbejeck merged 2 commits into
apache:trunkfrom
cadonna:fix_valueSerde_in_MeteredWindowStore

Conversation

@cadonna

@cadonna cadonna commented May 24, 2019

Copy link
Copy Markdown
Member

Committer Checklist (excluded from commit message)

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

@cadonna

cadonna commented May 24, 2019

Copy link
Copy Markdown
Member Author

@guozhangwang guozhangwang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

}

@Test
public void shouldNotThrowExceptionIfSerdesCorrectlySetFromProcessorContext() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add those test for MeteredTimestampedKeyValueStoreTest, too. We had the same bug in MeteredTimestampedKeyValueStore and fixed it "on the side" but never added a test...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will open a separate PR for that.


try {
store.put("key", ValueAndTimestamp.make(42L, 60000));
} catch (final StreamsException exception) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand this ? Why do we catch StreamsException? Should the test not just fail if an exception is thrown?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To distinguish between a test failure and a test that is terminated by an exception. If a StreamsException that caused by a ClassCastException was thrown by store.put(), then the test failed because the behaviour under test was not correct, otherwise it was terminated due to some other issues.


try {
store.put("key", ValueAndTimestamp.make(42L, 60000));
} catch (final StreamsException exception) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As above

@bbejeck bbejeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just one minor comment, otherwise LGTM

try {
store.put("key", ValueAndTimestamp.make(42L, 60000));
} catch (final StreamsException exception) {
if (exception.getCause() instanceof ClassCastException) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: IMHO we should just get rid of the try/catch as if the cause is anything other than a ClassCastException this test will still pass.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will add an else branch and re-throw the exception. That will still distinguish between a failed and a terminated test as explained above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree with @bbejeck (compare my other comment about "why we catch StreamsException) -- if any exception is thrown, the test should fail. We don't gain anything IMHO by calling fail vs re-throwing -- it's just confusing the read the test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OK, I see that the tests fail in any case when an exception is thrown. However, I still think that catching StreamException and checking if ClassCastException is its cause is a good idea to document what this test is verifying. Without the try-catch it is just a couple of lines of code without any assert, which may be puzzling when read in a couple of month. Additionally, the distinction between misbehaviour of code under test (i.e. test fails with predefined message in test) and other issue (some exception was thrown) seems still relevant to me for debugging.

If you both still do not agree, I will remove the try-catch clause for the sake of getting this bugfix in.

try {
store.put("key", ValueAndTimestamp.make(42L, 60000));
} catch (final StreamsException exception) {
if (exception.getCause() instanceof ClassCastException) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same as above

@bbejeck

bbejeck commented May 27, 2019

Copy link
Copy Markdown
Member

Java 8 and Java 11 failed, test results already cleaned up.

retest this please

@bbejeck

bbejeck commented May 28, 2019

Copy link
Copy Markdown
Member

OK, I see that the tests fail in any case when an exception is thrown. However, I still think that catching StreamException and checking if ClassCastException is its cause is a good idea to document what this test is verifying. Without the try-catch it is just a couple of lines of code without any assert, which may be puzzling when read in a couple of month. Additionally, the distinction between misbehaviour of code under test (i.e. test fails with predefined message in test) and other issue (some exception was thrown) seems still relevant to me for debugging.

Fair enough, maybe we can revisit this in a follow-on PR. Merging to get the bug fix in.

@bbejeck
bbejeck merged commit 94195f8 into apache:trunk May 28, 2019
@bbejeck

bbejeck commented May 28, 2019

Copy link
Copy Markdown
Member

Merged to trunk

bbejeck pushed a commit that referenced this pull request May 28, 2019
…6808)

Guozhang Wang <wangguoz@gmail.com>, Matthias J. Sax <mjsax@apache.org>,  Bill Bejeck <bbejeck@gmail.com>
@bbejeck

bbejeck commented May 28, 2019

Copy link
Copy Markdown
Member

cherry-picked to 2.3

haidangdam pushed a commit to haidangdam/kafka that referenced this pull request May 29, 2019
…pache#6808)

Guozhang Wang <wangguoz@gmail.com>, Matthias J. Sax <mjsax@apache.org>,  Bill Bejeck <bbejeck@gmail.com>
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…pache#6808)

Guozhang Wang <wangguoz@gmail.com>, Matthias J. Sax <mjsax@apache.org>,  Bill Bejeck <bbejeck@gmail.com>
@cadonna
cadonna deleted the fix_valueSerde_in_MeteredWindowStore branch October 21, 2019 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants