fix(lambda): destroy container handle on interrupt and generic exception (#530)

Closes #525.

Extends #529's timeout-path fix to the two remaining paths in
LambdaExecutorService.executeSync that were still returning a
potentially-dirty container to the warm pool.

- InterruptedException: the container may still be processing the
  previous request, so the response from the old invocation could be
  returned to a new one. Destroy the handle instead of releasing it.
- Exception (e.g. runtime API communication failure): container state
  is unknown. Destroy rather than trust it for reuse.

Matches AWS Lambda behavior where a container is discarded after any
internal error, not reused.

Tests mirror the existing timeoutInvocation_destroysHandle_doesNotRelease
pattern, one for each path.
This commit is contained in:
TiM authored and GitHub committed 2026-04-19 19:33:09 -05:00
1 parent 571d6d7a0d
commit 1b53e53dba
2 files changed
+58 -2

No files matched your search

@@ -113,11 +113,11 @@ public class LambdaExecutorService {
null, requestId);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
warmPool.release(handle);
warmPool.destroyHandle(handle);
return new InvokeResult(200, "Unhandled", buildErrorPayload("Invocation interrupted", "Interrupted"), null, requestId);
} catch (Exception e) {
LOG.warnv("Invocation error for function {0}: {1}", fn.getFunctionName(), e.getMessage());
warmPool.release(handle);
warmPool.destroyHandle(handle);
return new InvokeResult(200, "Unhandled", buildErrorPayload(e.getMessage(), "InvocationError"), null, requestId);
}
}