Use try-with-resources for AutoClosables where feasible

Where unfeasible, this commit adds inline comments to explain why
try-with-resources must not be used in certain scenarios. The purpose
of the comments is to avoid accidental conversion to try-with-resources
at a later date.

Closes gh-27823
This commit is contained in:
Marten Deinum
2021-12-16 07:10:12 +01:00
committed by Sam Brannen
parent 999376f9f9
commit e1200f34e7
6 changed files with 11 additions and 4 deletions

View File

@@ -374,6 +374,8 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
headerAccessor.setMessage(error.getMessage());
byte[] bytes = this.stompEncoder.encode(headerAccessor.getMessageHeaders(), EMPTY_PAYLOAD);
// We cannot use try-with-resources here as, potential, exception upon closing
// would still bubble up the stack
try {
session.sendMessage(new TextMessage(bytes));
}