Skip to content

KAFKA-14007: Invoking connect headers.close method on shutdown#12309

Merged
C0urante merged 5 commits intoapache:trunkfrom
vamossagar12:KAFKA-14007
Jul 28, 2022
Merged

KAFKA-14007: Invoking connect headers.close method on shutdown#12309
C0urante merged 5 commits intoapache:trunkfrom
vamossagar12:KAFKA-14007

Conversation

@vamossagar12
Copy link
Contributor

The HeaderConverter interface extends Closeable, but HeaderConverter::close is never actually invoked anywhere. We can and should start invoking it, probably wrapped in Utils::closeQuietly so that any invalid logic in that method for custom header converters that has to date gone undetected will not cause new task failures.

This PR addresses the above concern by invoking HeaderConverter.close in cases of shutdowns.

@vamossagar12
Copy link
Contributor Author

@C0urante , plz review whenever you get the chance.

@C0urante
Copy link
Contributor

@vamossagar12 there are test failures because the calls to HeaderConverter::close aren't expected in our unit tests right now. Can you update the unit tests to expect these calls where appropriate?

For future reference, you can run unit tests locally with ./gradlew :connect:runtime:unitTest, and most IDEs (including IntellIJ) also have support for running tests in them.

@vamossagar12
Copy link
Contributor Author

@C0urante , I did run the unit tests before pushing the changes the first time around but instead of running connect:unitTests, ran it for some other sub-task. Sorry about that
I have made the relevant changes to the PR.

Copy link
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

Looks good! Two small comments but apart from that, 👍

BTW, regarding this:

I did run the unit tests before pushing the changes the first time around but instead of running connect:unitTests, ran it for some other sub-task.

I think that's the problem--funnily enough, the :connect:unitTest task (and also :connect:test) doesn't actually run any tests. You want to use connect:runtime:unitTest (or connect:runtime:test) instead.

Comment on lines 107 to 108
this.serializer.close();
this.deserializer.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch here. Should we do the same in the NumberConverter class?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, even though these are no-ops right now, if we want to be meticulous about the cleanup logic here, should we wrap both of these in Utils::closeQuietly, so that if one fails, we still get a chance to close the other?

@vamossagar12
Copy link
Contributor Author

Details

Looks good! Two small comments but apart from that, 👍

BTW, regarding this:

I did run the unit tests before pushing the changes the first time around but instead of running connect:unitTests, ran it for some other sub-task.

I think that's the problem--funnily enough, the :connect:unitTest task (and also :connect:test) doesn't actually run any tests. You want to use connect:runtime:unitTest (or connect:runtime:test) instead.

Thanks. I have made those changes. Also, thanks for the information on the connect test tasks 👍

…onverter.java

Co-authored-by: Chris Egerton <fearthecellos@gmail.com>

@Override
public void close() {
Utils.closeQuietly(this.serializer, "number format serializer");
Copy link
Contributor

Choose a reason for hiding this comment

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

What is format? Would number converter serializer or even just number serializer make more sense here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to number converter serializer. Somehow had NumberFormatException in my mind when I was making this change and ended up writing number format serializer

Copy link
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

LGTM, one more small comment. You'll also want to update the JsonConverter to import the Utils class or the class won't compile.

Copy link
Contributor

@C0urante C0urante left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @vamossagar12

@vamossagar12
Copy link
Contributor Author

Thanks @C0urante . How to get this PR merged though :)

@C0urante
Copy link
Contributor

This needs to be reviewed by a committer now. @showuon might be able to take a look?

@vamossagar12
Copy link
Contributor Author

This needs to be reviewed by a committer now. @showuon might be able to take a look?

Thanks Chris!. @showuon , could you plz review as well whenever you get the chance? Thanks!

@vamossagar12
Copy link
Contributor Author

@showuon , can you plz review the changes? Thanks!

@vamossagar12
Copy link
Contributor Author

@showuon could you plz review/merge this? Thanks!

@vamossagar12
Copy link
Contributor Author

@C0urante same as the other PR, I think you can merge this now :)

@C0urante
Copy link
Contributor

@vamossagar12 ah yeah, thanks for the ping! I'll merge this one tonight and take a final look at #12321 tomorrow; please ping me again if there's no activity on it by the end of the day.

@C0urante C0urante merged commit 0c5f5a7 into apache:trunk Jul 28, 2022
@vamossagar12
Copy link
Contributor Author

Thanks @C0urante !

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.

3 participants