Skip to content

Fix structured concurrency test on jdk 25 #13936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.executors;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

import io.opentelemetry.context.Context;
Expand All @@ -24,7 +25,10 @@ public class StructuredTaskScopeInstrumentation implements TypeInstrumentation {

@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return named("java.util.concurrent.StructuredTaskScope");
return namedOneOf(
"java.util.concurrent.StructuredTaskScope",
// since jdk 25-ea+24
"java.util.concurrent.StructuredTaskScopeImpl");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,24 @@ class StructuredTaskScopeTest {
@RegisterExtension
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();

@SuppressWarnings({
"unchecked",
"rawtypes"
}) // type arguments for StructuredTaskScope change between jdk 21 and 25
@Test
void multipleForkJoin() throws Exception {
StructuredTaskScope<Object> taskScope = new StructuredTaskScope.ShutdownOnFailure();
StructuredTaskScope tmp;
try {
// since jdk 25-ea+24
tmp = (StructuredTaskScope) StructuredTaskScope.class.getMethod("open").invoke(null);
} catch (NoSuchMethodException exception) {
tmp =
Class.forName("java.util.concurrent.StructuredTaskScope$ShutdownOnFailure")
.asSubclass(StructuredTaskScope.class)
.getConstructor()
.newInstance();
}
StructuredTaskScope taskScope = tmp;

Callable<String> callable1 =
() -> {
Expand Down
Loading