Skip to content

Commit a16d9f1

Browse files
authored
Merge pull request #37 from javierfreire/unchaught
Fix #36; Avoid uncaught exception on timeout
2 parents 5138e62 + a28e866 commit a16d9f1

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/main/java/org/buildobjects/process/ByteArrayConsumptionThread.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public void run() {
3232
try {
3333
bytes = toByteArray(inputStream);
3434
} catch (Throwable t) {
35-
ByteArrayConsumptionThread.this.throwable = t;
36-
eventSink.dispatch(EXCEPTION_IN_STREAM_HANDLING);
35+
if (!thread.isInterrupted()) {
36+
ByteArrayConsumptionThread.this.throwable = t;
37+
eventSink.dispatch(EXCEPTION_IN_STREAM_HANDLING);
38+
}
3739
}
3840
}
3941
});

src/main/java/org/buildobjects/process/StreamConsumerConsumptionThread.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ public void run() {
2828
stdout.consume(inputStream);
2929

3030
} catch (Throwable t) {
31-
StreamConsumerConsumptionThread.this.throwable = t;
32-
eventSink.dispatch(EXCEPTION_IN_STREAM_HANDLING);
31+
if (!thread.isInterrupted()) {
32+
StreamConsumerConsumptionThread.this.throwable = t;
33+
eventSink.dispatch(EXCEPTION_IN_STREAM_HANDLING);
34+
}
3335
}
3436
}
3537
});

src/main/java/org/buildobjects/process/StreamCopyConsumptionThread.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ public void startConsumption(final InputStream inputStream) {
2525
public void run() {
2626
try {
2727
new StreamCopyRunner(inputStream, stdout, false).run();
28-
} catch (Throwable t) {
29-
StreamCopyConsumptionThread.this.throwable = t;
30-
eventSink.dispatch(EXCEPTION_IN_STREAM_HANDLING);
28+
} catch (Throwable t) {
29+
if (!thread.isInterrupted()) {
30+
StreamCopyConsumptionThread.this.throwable = t;
31+
eventSink.dispatch(EXCEPTION_IN_STREAM_HANDLING);
32+
}
33+
}
3134
}
32-
}});
35+
});
3336
this.thread.start();
3437
}
3538

0 commit comments

Comments
 (0)