Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MockLogAppender itself Releasable #108526

Merged
merged 3 commits into from May 13, 2024

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented May 10, 2024

Existing uses of MockLogAppender first construct an appender, then call capturing on the instance in a try-with-resources block. This commit adds a new method, capture, which creates an appender and sets up the capture the the same time. The intent is that this will replace the existing capturing calls, but there are too many to change in one PR.

Existing uses of MockLogAppender first construct an appender, then call
capturing on the instance in a try-with-resources block. This commit
adds a new method, capture, which creates an appender and sets up the
capture the the same time. The intent is that this will replace the
existing capturing calls, but there are too many to change in one PR.
@rjernst rjernst added >test Issues or PRs that are addressing/adding tests :Core/Infra/Logging Log management and logging utilities labels May 10, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine elasticsearchmachine added v8.15.0 Team:Core/Infra Meta label for core/infra team labels May 10, 2024
/**
* Adds the list of class loggers to this {@link MockLogAppender}.
*
* Stops and runs some checks on the {@link MockLogAppender} once the returned object is released.
*/
public Releasable capturing(Class<?>... classes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused: you stated in the description that you wanted to replace capturing gradually (hence the non-provate MockLogAppender ctor), but here you are removing them. What am I missing?

Copy link
Member Author

Choose a reason for hiding this comment

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

They still exist, just above this. The diff shows weird because the javadoc is moved to the new method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah! Got it. Yes, the diff was confusing.

Copy link
Contributor

@ldematte ldematte 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, and ++ to making the changes and removal of capturing in follow-ups

@rjernst rjernst merged commit b02d06c into elastic:main May 13, 2024
15 checks passed
@rjernst rjernst deleted the test/mock_appender_try branch May 13, 2024 14:51
rjernst added a commit to rjernst/elasticsearch that referenced this pull request May 15, 2024
nicktindall pushed a commit to nicktindall/elasticsearch that referenced this pull request May 17, 2024
parkertimmins pushed a commit to parkertimmins/elasticsearch that referenced this pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Logging Log management and logging utilities Team:Core/Infra Meta label for core/infra team >test Issues or PRs that are addressing/adding tests v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants