Skip to content

Commit 32e5139

Browse files
committed
record failures
1 parent 703e45c commit 32e5139

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

api/client/src/testFixtures/java/org/projectnessie/client/auth/oauth2/InteractiveResourceOwnerEmulator.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.List;
4040
import java.util.Map;
4141
import java.util.Set;
42+
import java.util.concurrent.CompletableFuture;
4243
import java.util.concurrent.ExecutorService;
4344
import java.util.concurrent.Executors;
4445
import java.util.concurrent.TimeUnit;
@@ -90,7 +91,18 @@ public InteractiveResourceOwnerEmulator(String username, String password, SSLCon
9091
Executors.newFixedThreadPool(
9192
2, r -> new Thread(r, getClass().getSimpleName() + COUNTER.getAndIncrement()));
9293
standardOut = System.out;
93-
executor.submit(this::readConsole);
94+
submitAndRecordFailure(this::readConsole);
95+
}
96+
97+
protected void submitAndRecordFailure(Runnable runnable) {
98+
CompletableFuture.runAsync(runnable, executor)
99+
.whenComplete(
100+
(r, ex) -> {
101+
if (ex != null) {
102+
LOGGER.error("Error in async job", ex);
103+
recordFailure(ex);
104+
}
105+
});
94106
}
95107

96108
@Override
@@ -127,7 +139,7 @@ private void readConsole() {
127139
standardOut.flush();
128140
Runnable flow = processLine(line);
129141
if (flow != null) {
130-
executor.submit(flow);
142+
submitAndRecordFailure(flow);
131143
}
132144
}
133145
} catch (IOException ignored) {

0 commit comments

Comments
 (0)