From 00b130822358d9e58901d5363ee4dddf1ff707cb Mon Sep 17 00:00:00 2001 From: Chris Collins Date: Thu, 15 Mar 2018 11:16:49 -0300 Subject: [PATCH] Make lastException from initialize() available During each run of initialize() an exception could be encountered, this makes that exception available via a getter to whatever created the thread to be able to take further action with it. --- .../kinesis/clientlibrary/lib/worker/Worker.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/amazonaws/services/kinesis/clientlibrary/lib/worker/Worker.java b/src/main/java/com/amazonaws/services/kinesis/clientlibrary/lib/worker/Worker.java index 4a03b449..bc8861d3 100644 --- a/src/main/java/com/amazonaws/services/kinesis/clientlibrary/lib/worker/Worker.java +++ b/src/main/java/com/amazonaws/services/kinesis/clientlibrary/lib/worker/Worker.java @@ -104,6 +104,7 @@ public class Worker implements Runnable { private volatile boolean shutdown; private volatile long shutdownStartTimeMillis; private volatile boolean shutdownComplete = false; + private volatile Exception lastException = null; // Holds consumers for shards the worker is currently tracking. Key is shard // info, value is ShardConsumer. @@ -617,7 +618,6 @@ public class Worker implements Runnable { private void initialize() { workerStateChangeListener.onWorkerStateChange(WorkerStateChangeListener.WorkerState.INITIALIZING); boolean isDone = false; - Exception lastException = null; for (int i = 0; (!isDone) && (i < MAX_INITIALIZATION_ATTEMPTS); i++) { try { @@ -881,6 +881,14 @@ public class Worker implements Runnable { WorkerStateChangeListener getWorkerStateChangeListener() { return workerStateChangeListener; } + + /** + * The last of any exception encountered during initialize() will be available here + */ + public Exception getLastException() + { + return lastException; + } /** * Signals worker to shutdown. Worker will try initiating shutdown of all record processors. Note that if executor