From 55eabaee558fde0e5acd739f3faeb67fd0df717c Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Tue, 13 Jun 2023 18:00:05 +0000 Subject: [PATCH] GUACAMOLE-1803: Fix potential sulf-suppression error. --- .../connection/HistoryConnectionRecord.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/extensions/guacamole-history-recording-storage/src/main/java/org/apache/guacamole/history/connection/HistoryConnectionRecord.java b/extensions/guacamole-history-recording-storage/src/main/java/org/apache/guacamole/history/connection/HistoryConnectionRecord.java index fbc7bdf08..f1c53ff87 100644 --- a/extensions/guacamole-history-recording-storage/src/main/java/org/apache/guacamole/history/connection/HistoryConnectionRecord.java +++ b/extensions/guacamole-history-recording-storage/src/main/java/org/apache/guacamole/history/connection/HistoryConnectionRecord.java @@ -131,7 +131,9 @@ public class HistoryConnectionRecord extends DelegatingConnectionRecord { */ private boolean isSessionRecording(File file) { - try (Reader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) { + Reader reader = null; + try { + reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8); GuacamoleReader guacReader = new ReaderGuacamoleReader(reader); if (guacReader.readInstruction() != null) @@ -148,6 +150,24 @@ public class HistoryConnectionRecord extends DelegatingConnectionRecord { + "identified as it cannot be read: {}", file, e.getMessage()); logger.debug("Possible session recording \"{}\" could not be read.", file, e); } + finally { + + // If the reader was successfully constructed, close it + if (reader != null) { + + try { + reader.close(); + } + + catch (IOException e) { + logger.warn("Unexpected error closing recording file \"{}\": {}", + file, e.getMessage()); + logger.debug("Session recording file \"{}\" could not be closed.", + file, e); + } + + } + } return false;