Skip to content
Open
Changes from all commits
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 @@ -16,7 +16,7 @@
package org.springframework.shell.core;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -83,14 +83,15 @@ else if (args[0].startsWith("@")) {
}

private void executeScript(File script) {
InputProvider inputProvider;
try {
inputProvider = new FileInputProvider(script);
try (FileInputProvider inputProvider = new FileInputProvider(script)) {
executeScript(inputProvider);
}
catch (FileNotFoundException e) {
catch (IOException e) {
log.error("Unable to locate script file", e);
return;
}
}

private void executeScript(InputProvider inputProvider) {
while (true) {
String input;
try {
Expand All @@ -100,14 +101,14 @@ private void executeScript(File script) {
log.error("Unable to read command", e);
break;
}
if (input.isEmpty()) {
// ignore empty lines
continue;
}
if (input == null) {
// break on end of file
break;
}
if (input.isEmpty()) {
// ignore empty lines
continue;
}
ParsedInput parsedInput;
try {
parsedInput = this.commandParser.parse(input);
Expand Down