Skip to content

Commit 87e9c19

Browse files
committed
Ensure errors in callback are processed and logged
1 parent e3a0847 commit 87e9c19

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/main/java/com/github/dockerjava/core/async/ResultCallbackTemplate.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import java.util.concurrent.CountDownLatch;
99
import java.util.concurrent.TimeUnit;
1010

11+
import org.slf4j.Logger;
12+
import org.slf4j.LoggerFactory;
13+
1114
import com.github.dockerjava.api.async.ResultCallback;
1215

1316
/**
@@ -18,6 +21,8 @@
1821
*/
1922
public abstract class ResultCallbackTemplate<T> implements ResultCallback<T> {
2023

24+
private final static Logger LOGGER = LoggerFactory.getLogger(ResultCallbackTemplate.class);
25+
2126
private final CountDownLatch finished = new CountDownLatch(1);
2227

2328
private Closeable stream;
@@ -34,6 +39,7 @@ public void onNext(T object) {
3439
@Override
3540
public void onError(Throwable throwable) {
3641
try {
42+
LOGGER.error("Error during callback", throwable);
3743
throw new RuntimeException(throwable);
3844
} finally {
3945
try {

src/main/java/com/github/dockerjava/jaxrs/async/AbstractCallbackNotifier.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public Void call() throws Exception {
4848
resultCallback.onError(e.getCause());
4949
}
5050
return null;
51+
} catch (Exception e) {
52+
if (resultCallback != null) {
53+
resultCallback.onError(e);
54+
}
55+
return null;
5156
}
5257

5358
try {

0 commit comments

Comments
 (0)