diff options
author | Simon Rettberg | 2017-04-21 17:12:12 +0200 |
---|---|---|
committer | Simon Rettberg | 2017-04-21 17:12:12 +0200 |
commit | 85cd89e7f7bba864fba687fbf419512504b5f7c2 (patch) | |
tree | caeac959383f0a092ca5ad0df1bb2b81d792c6e1 | |
parent | Better error logging: Include exception in some logger calls (diff) | |
download | taskman-lite-85cd89e7f7bba864fba687fbf419512504b5f7c2.tar.gz taskman-lite-85cd89e7f7bba864fba687fbf419512504b5f7c2.tar.xz taskman-lite-85cd89e7f7bba864fba687fbf419512504b5f7c2.zip |
[SystemCommandTask] try-with for stdout/err readers, close input after done
-rw-r--r-- | api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java b/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java index 2f3cf57..3e480de 100644 --- a/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java +++ b/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java @@ -67,8 +67,7 @@ public abstract class SystemCommandTask extends AbstractTask @Override public void run() { - try { - BufferedReader reader = new BufferedReader( new InputStreamReader( p.getInputStream() ) ); + try ( BufferedReader reader = new BufferedReader( new InputStreamReader( p.getInputStream() ) ) ) { String line; while ( ( line = reader.readLine() ) != null ) { synchronized ( p ) { @@ -85,8 +84,7 @@ public abstract class SystemCommandTask extends AbstractTask @Override public void run() { - try { - BufferedReader reader = new BufferedReader( new InputStreamReader( p.getErrorStream() ) ); + try ( BufferedReader reader = new BufferedReader( new InputStreamReader( p.getErrorStream() ) ) ) { String line; while ( ( line = reader.readLine() ) != null ) { synchronized ( p ) { @@ -135,6 +133,10 @@ public abstract class SystemCommandTask extends AbstractTask process.getOutputStream().close(); } catch ( Throwable t ) { } + try { + process.getInputStream().close(); + } catch ( Throwable t ) { + } synchronized ( p ) { return processEnded( retval ); |