Skip to content

Commit

Permalink
Refactor SingleConnectionFactory to use try-with-resource
Browse files Browse the repository at this point in the history
Refactored SingleConnectionFactory in the spring-jms module to use try-with-resource for managing the JMS connection. This eliminates the necessity to explicitly close the connection, thereby enhancing code readability and exception handling.
  • Loading branch information
alidandach committed Apr 9, 2024
1 parent 2d40868 commit 176efa4
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,11 @@ protected void closeConnection(Connection con) {
logger.debug("Closing shared JMS Connection: " + con);
}
try {
try {
try (con) {
if (this.startedCount > 0) {
con.stop();
}
}
finally {
con.close();
}
}
catch (jakarta.jms.IllegalStateException ex) {
logger.debug("Ignoring Connection state exception - assuming already closed: " + ex);
Expand Down

0 comments on commit 176efa4

Please sign in to comment.