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

Don't create a Thread when there is no thread #2514

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

psalagnac
Copy link
Contributor

No Jira.
This is just to clean-up a bad smell in the code.

Description

We create a java.lang.Thread instance, but this thread is never started. It just acts as a target for another existing thread, from the executor pool. The call to setDaemon() has no effect.

This code was reported by errorprone because of the thread creation without a name (hence the removed @SuppressForbidden)

Replacing the thread by a Runnable makes the full thing cleaner.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

Cool. You could even inline the Runnable.

@epugh
Copy link
Contributor

epugh commented Jun 19, 2024

@dsmiley wpuld you like me to shepherd merging this? It looks ready?

@dsmiley dsmiley merged commit d567066 into apache:main Jul 22, 2024
3 checks passed
dsmiley pushed a commit that referenced this pull request Jul 22, 2024
@psalagnac psalagnac deleted the no-thread branch July 23, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants