Skip to content

Commit

Permalink
Merge pull request spring-projects#32610 from alidandach
Browse files Browse the repository at this point in the history
* pr/32610:
  Polish "Use try-with-resources when applicable"
  Use try-with-resources when applicable

Closes spring-projectsgh-32610
  • Loading branch information
snicoll committed Apr 10, 2024
2 parents 2d40868 + 330dcf1 commit 3d85ec2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 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
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,9 @@ public static void closeConnection(@Nullable Connection con, boolean stop) {
if (con != null) {
try {
if (stop) {
try {
try (con) {
con.stop();
}
finally {
con.close();
}
}
else {
con.close();
Expand Down

0 comments on commit 3d85ec2

Please sign in to comment.