summaryrefslogtreecommitdiffstats
path: root/api/src
diff options
context:
space:
mode:
authorSimon Rettberg2017-04-21 17:12:12 +0200
committerSimon Rettberg2017-04-21 17:12:12 +0200
commit85cd89e7f7bba864fba687fbf419512504b5f7c2 (patch)
treecaeac959383f0a092ca5ad0df1bb2b81d792c6e1 /api/src
parentBetter error logging: Include exception in some logger calls (diff)
downloadtaskman-lite-85cd89e7f7bba864fba687fbf419512504b5f7c2.tar.gz
taskman-lite-85cd89e7f7bba864fba687fbf419512504b5f7c2.tar.xz
taskman-lite-85cd89e7f7bba864fba687fbf419512504b5f7c2.zip
[SystemCommandTask] try-with for stdout/err readers, close input after done
Diffstat (limited to 'api/src')
-rw-r--r--api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java10
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 );