From 9b733e25fae0483c06b520d31255ac9de0260b21 Mon Sep 17 00:00:00 2001 From: Paul Thevenot Date: Fri, 4 Jan 2019 18:17:08 +0100 Subject: [PATCH] stream close to avoid conflict when using git scriptler repo --- .../jenkinsci/plugins/scriptler/util/ScriptHelper.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/scriptler/util/ScriptHelper.java b/src/main/java/org/jenkinsci/plugins/scriptler/util/ScriptHelper.java index 28efd84..3052eb2 100644 --- a/src/main/java/org/jenkinsci/plugins/scriptler/util/ScriptHelper.java +++ b/src/main/java/org/jenkinsci/plugins/scriptler/util/ScriptHelper.java @@ -3,9 +3,11 @@ import hudson.model.Computer; import hudson.util.StreamTaskListener; +import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; @@ -70,9 +72,9 @@ public class ScriptHelper { } Script s = ScriptlerConfiguration.getConfiguration().getScriptById(id); if (withSrc && s != null) { - try { - File scriptSrc = new File(ScriptlerManagement.getScriptDirectory(), s.getScriptPath()); - Reader reader = new InputStreamReader(new FileInputStream(scriptSrc), Charset.forName("UTF-8")); + File scriptSrc = new File(ScriptlerManagement.getScriptDirectory(), s.getScriptPath()); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(scriptSrc), + Charset.forName("UTF-8")))) { String src = IOUtils.toString(reader); s.setScript(src); } catch (IOException e) {