Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use try-with-resource to close BufferedReaders #1020

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();) {
bbortt marked this conversation as resolved.
Show resolved Hide resolved
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));) {
bbortt marked this conversation as resolved.
Show resolved Hide resolved
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
Loading