Skip to content

Commit

Permalink
fix(#1020): use try-with-resource to close buffered readers
Browse files Browse the repository at this point in the history
* Use try-with-resource to close BufferedReaders

* Remove unnecessary semi-colons
  • Loading branch information
picimako authored Oct 17, 2023
1 parent bee0cd2 commit 85fdbb3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 85fdbb3

Please sign in to comment.