From 2e5544fa59ad8ed2a893260532e536a11a8bb075 Mon Sep 17 00:00:00 2001 From: Jack Berg <34418638+jack-berg@users.noreply.github.com> Date: Tue, 14 Apr 2026 11:47:48 -0500 Subject: [PATCH] Protect against index out of bounds exception --- .../java/io/opentelemetry/context/StrictContextStorage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/context/src/main/java/io/opentelemetry/context/StrictContextStorage.java b/context/src/main/java/io/opentelemetry/context/StrictContextStorage.java index 3c8fa72c2e5..cf516414b82 100644 --- a/context/src/main/java/io/opentelemetry/context/StrictContextStorage.java +++ b/context/src/main/java/io/opentelemetry/context/StrictContextStorage.java @@ -180,7 +180,8 @@ public void close() { maybeResumeWithFrameIndex = i + 3; } } - if (stackTrace[maybeResumeWithFrameIndex].getMethodName().equals("invokeSuspend")) { + if (maybeResumeWithFrameIndex < stackTrace.length + && stackTrace[maybeResumeWithFrameIndex].getMethodName().equals("invokeSuspend")) { // Skip synthetic invokeSuspend function. // NB: The stacktrace showed in an IntelliJ debug pane does not show this. maybeResumeWithFrameIndex++;