Skip to content

Use try-with-resources for ExecutorService in ExpectTest - #1640

Open
Aaron-PintoTamayo wants to merge 1 commit into
google:masterfrom
Aaron-PintoTamayo:quality/cleaner-code-with-try
Open

Aaron-PintoTamayo wants to merge 1 commit into
google:masterfrom
Aaron-PintoTamayo:quality/cleaner-code-with-try

Conversation

@Aaron-PintoTamayo

Copy link
Copy Markdown

Relates to #1624

Following a suggestion from @cpovirk, refactor the executors in ExpectTest to use try-with-resources instead of manual shutdown() calls. This improves code cleanliness and ensures executors are always closed even if an exception occurs, without affecting test isolation or readability.

@cpovirk

cpovirk commented Mar 26, 2026

Copy link
Copy Markdown
Member

Ah, sorry, the CI shows trouble with Java version compatibility.... Maybe we even tried this before? Sigh.

@Aaron-PintoTamayo

Aaron-PintoTamayo commented Mar 26, 2026

Copy link
Copy Markdown
Author

I could use a finally block which guarantees shutdown on exception and works with the JDK, but I honestly think that may not be worth the added verbosity for test code and doesn't benefit it given the situation. I will dive deep into the repo and learn more about other areas. I am a bit new to this I can close the PR based on feedback.

@chaoren chaoren added P3 not scheduled type=other Miscellaneous activities not covered by other type= labels labels Mar 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 not scheduled type=other Miscellaneous activities not covered by other type= labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants