diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/InputAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/InputAction.java index ee67ccdc89..da3dd155e0 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/InputAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/InputAction.java @@ -91,11 +91,9 @@ public void doExecute(TestContext context) { } - try { + try (BufferedReader stdin = getInputReader()) { do { logger.info(display); - - BufferedReader stdin = getInputReader(); input = stdin.readLine(); } while (validAnswers != null && !checkAnswer(input)); } catch (IOException e) { diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/script/TemplateBasedScriptBuilder.java b/core/citrus-base/src/main/java/org/citrusframework/validation/script/TemplateBasedScriptBuilder.java index 4e134efa1d..ceeb42adbb 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/script/TemplateBasedScriptBuilder.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/script/TemplateBasedScriptBuilder.java @@ -64,9 +64,8 @@ public String build() { StringBuilder scriptBody = new StringBuilder(); String importStmt = "import "; - try { + try (BufferedReader reader = new BufferedReader(new StringReader(scriptCode))) { if (scriptCode.contains(importStmt)) { - BufferedReader reader = new BufferedReader(new StringReader(scriptCode)); String line; while ((line = reader.readLine()) != null) { if (line.trim().startsWith(importStmt)) {