GUACAMOLE-1803: Fix potential sulf-suppression error.

This commit is contained in:
James Muehlner
2023-06-13 18:00:05 +00:00
parent b8de8ebb90
commit 55eabaee55

View File

@@ -131,7 +131,9 @@ public class HistoryConnectionRecord extends DelegatingConnectionRecord {
*/ */
private boolean isSessionRecording(File file) { 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); GuacamoleReader guacReader = new ReaderGuacamoleReader(reader);
if (guacReader.readInstruction() != null) if (guacReader.readInstruction() != null)
@@ -148,6 +150,24 @@ public class HistoryConnectionRecord extends DelegatingConnectionRecord {
+ "identified as it cannot be read: {}", file, e.getMessage()); + "identified as it cannot be read: {}", file, e.getMessage());
logger.debug("Possible session recording \"{}\" could not be read.", file, e); 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; return false;