AutoClosable Client#232
Merged
tonygermano merged 2 commits intoOpenIntegrationEngine:mainfrom Jan 1, 2026
Merged
Conversation
NicoPiel
reviewed
Dec 24, 2025
mgaffigan
approved these changes
Dec 24, 2025
Contributor
|
I love boring refactors! |
There was a problem hiding this comment.
Pull request overview
This pull request enhances the Client class by making it AutoCloseable and improving immutability through making several fields final. The changes enable the Client to be used with try-with-resources statements while ensuring thread-safe, idempotent resource cleanup.
Key changes:
- Made five private fields (
logger,serverConnection,client,api,closed) final to prevent reassignment - Implemented the AutoCloseable interface to support try-with-resources usage
- Enhanced the
close()method to be idempotent and thread-safe using atomic operations
Comments suppressed due to low confidence (1)
server/src/com/mirth/connect/client/core/Client.java:325
- The new AutoCloseable functionality and idempotent close() implementation lack test coverage. Consider adding tests to verify:
- Multiple calls to close() are safe and only shutdown resources once
- Client can be used with try-with-resources
- Calling close() properly shuts down both serverConnection and the JAX-RS client
@Override
public void close() {
if (!closed.getAndSet(true)) {
serverConnection.shutdown();
client.close();
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
These fields are all either initialized in their declarations or in the constructor and then never reassigned. Signed-off-by: Tony Germano <tony@germano.name>
- Make AutoClosable so it can be used in try-with-resources - Removed null check for serverConnection since it cannot be null - Do not shutdown serverConnection or close JAX-RS client if this client is already closed. Signed-off-by: Tony Germano <tony@germano.name>
6c2dbfe to
8e040c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit 1
Commit 2