File tree Expand file tree Collapse file tree
sdk/src/main/java/software/amazon/lambda/durable/execution Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -223,11 +223,26 @@ public void deregisterActiveThread(String threadId) {
223223
224224 if (activeThreads .isEmpty ()) {
225225 logger .info ("No active threads remaining - suspending execution" );
226+ preSuspendCheck ();
226227 suspendExecution ();
227228 }
228229 }
229230 }
230231
232+ private void preSuspendCheck () {
233+ if (executionExceptionFuture .isDone ()) {
234+ throw new IllegalStateException ("Execution already suspended" );
235+ }
236+
237+ operationStorage .values ().stream ()
238+ .filter (op -> !isTerminalStatus (op .status ()))
239+ .findFirst ()
240+ .ifPresentOrElse (op -> logger .debug ("Some operations pending" ), () -> {
241+ logger .warn ("There is no operation still in progress" );
242+ throw new IllegalStateException ("Cannot suspend execution without an operation in progress" );
243+ });
244+ }
245+
231246 // ===== Checkpointing =====
232247
233248 // This method will checkpoint the operation updates to the durable backend and return a future which completes
You can’t perform that action at this time.
0 commit comments