From c964d84f38bb9b95a0ea851a8683d23fbaa844ef Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Thu, 13 Oct 2016 21:51:20 +0200 Subject: [PATCH] SRUClient: Fix resource leak CID 44603 (#1 of 1): Resource leak (RESOURCE_LEAK) Signed-off-by: Stefan Weil --- .../com/googlecode/fascinator/redbox/sru/SRUClient.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Goobi/plugins/import/PicaMassImport/com/googlecode/fascinator/redbox/sru/SRUClient.java b/Goobi/plugins/import/PicaMassImport/com/googlecode/fascinator/redbox/sru/SRUClient.java index 4303c5f0422..29f7422e2ac 100644 --- a/Goobi/plugins/import/PicaMassImport/com/googlecode/fascinator/redbox/sru/SRUClient.java +++ b/Goobi/plugins/import/PicaMassImport/com/googlecode/fascinator/redbox/sru/SRUClient.java @@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.InputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; @@ -219,8 +220,12 @@ private void saxInit() { */ public void testResponseResource(String fileName) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); - IOUtils.copy(getClass().getResourceAsStream("/" + fileName), out); - testingResponseString = out.toString("UTF-8"); + InputStream in = getClass().getResourceAsStream("/" + fileName); + if (in != null) { + IOUtils.copy(in, out); + testingResponseString = out.toString("UTF-8"); + in.close(); + } } /**