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:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user