Merge pull request #32610 from alidandach

* pr/32610:
  Polish "Use try-with-resources when applicable"
  Use try-with-resources when applicable

Closes gh-32610
This commit is contained in:
Stéphane Nicoll
2024-04-10 09:52:25 +02:00
2 changed files with 2 additions and 8 deletions

View File

@@ -575,14 +575,11 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
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);

View File

@@ -74,12 +74,9 @@ public abstract class JmsUtils {
if (con != null) {
try {
if (stop) {
try {
try (con) {
con.stop();
}
finally {
con.close();
}
}
else {
con.close();