Skip to content

[fix][test] Fix resource leak in PulsarTestContext - #20799

Merged
lhotari merged 4 commits into
apache:masterfrom
lhotari:lh-fix-PulsarTestContext-resource-leak
Jul 13, 2023
Merged

[fix][test] Fix resource leak in PulsarTestContext#20799
lhotari merged 4 commits into
apache:masterfrom
lhotari:lh-fix-PulsarTestContext-resource-leak

Conversation

@lhotari

@lhotari lhotari commented Jul 13, 2023

Copy link
Copy Markdown
Member

Fixes #20797

Motivation

See #20797. There's a resource leak in PulsarTestContext which was introduced in #19337 and #19376.
PulsarTestContext was a solution that was made to reduce the usage of Mockito so that issues like #13620 could be fixed. Mockito is not thread safe and that is the reason why PulsarTestContext was needed.

Modifications

  • use fields in super class to hold resources instead of having duplicates
  • all fields in PulsarService have protected setters due to @Setter(AccessLevel.PROTECTED)
    • this fact was missed in the original implementation of PulsarTestContext

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: lhotari#152

- use fields in super class to hold resources instead of having
  duplicates
- all fields in PulsarService have protected setters due to `@Setter(AccessLevel.PROTECTED)`
  - this fact was missed in the original implementation of PulsarTestContext

@eolivelli eolivelli 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.

Great catch !
Thank you very much for fixing this long standing issue

@dave2wave dave2wave 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.

Awesome. Thanks!

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.

[Tests] Thread resource leaks in unit tests

6 participants