From 654be7e066e27cdd6b726e7fead37ce00c9cfe18 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Thu, 22 Jun 2023 02:48:42 -0400 Subject: [PATCH] fix(template): should truly close the inputstream --- .../java/io/cryostat/core/agent/LocalProbeTemplateService.java | 3 ++- src/main/java/io/cryostat/core/agent/ProbeTemplate.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/cryostat/core/agent/LocalProbeTemplateService.java b/src/main/java/io/cryostat/core/agent/LocalProbeTemplateService.java index 10e7cabc..9f979c8b 100644 --- a/src/main/java/io/cryostat/core/agent/LocalProbeTemplateService.java +++ b/src/main/java/io/cryostat/core/agent/LocalProbeTemplateService.java @@ -91,7 +91,8 @@ public ProbeTemplate addTemplate(InputStream inputStream, String filename) throws FileAlreadyExistsException, IOException, SAXException { Path path = fs.pathOf(env.getEnv(TEMPLATE_PATH), filename); if (fs.exists(path)) { - throw new FileAlreadyExistsException(filename); + throw new FileAlreadyExistsException( + String.format("Probe template \"%s\" already exists.", filename)); } try (inputStream) { ProbeTemplate template = new ProbeTemplate(); diff --git a/src/main/java/io/cryostat/core/agent/ProbeTemplate.java b/src/main/java/io/cryostat/core/agent/ProbeTemplate.java index fe5e4f36..13133f8b 100644 --- a/src/main/java/io/cryostat/core/agent/ProbeTemplate.java +++ b/src/main/java/io/cryostat/core/agent/ProbeTemplate.java @@ -107,7 +107,7 @@ public void deserialize(InputStream xmlStream) throws IOException, SAXException } Document document = builder.parse(stream); - stream.close(); + stream.trulyClose(); NodeList elements; // parse global configurations