Build with jdk21 (#11219)
This commit is contained in:
parent
c92955fa2f
commit
dfc79ebece
|
|
@ -69,7 +69,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
@ -68,7 +68,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
@ -138,7 +138,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Increase gradle daemon heap size
|
- name: Increase gradle daemon heap size
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -220,7 +220,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
# vaadin 14 tests fail with node 18
|
# vaadin 14 tests fail with node 18
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
|
|
@ -335,7 +335,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Set up Gradle cache
|
- name: Set up Gradle cache
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
@ -388,7 +388,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
@ -411,7 +411,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Set up Gradle cache
|
- name: Set up Gradle cache
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3
|
uses: github/codeql-action/init@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Increase gradle daemon heap size
|
- name: Increase gradle daemon heap size
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
@ -49,7 +49,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ jobs:
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Set up Gradle cache
|
- name: Set up Gradle cache
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ jobs:
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Login to GitHub package registry
|
- name: Login to GitHub package registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
|
@ -55,7 +55,7 @@ jobs:
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Login to GitHub package registry
|
- name: Login to GitHub package registry
|
||||||
uses: azure/docker-login@v1
|
uses: azure/docker-login@v1
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Login to GitHub package registry
|
- name: Login to GitHub package registry
|
||||||
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
|
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ jobs:
|
||||||
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Login to GitHub package registry
|
- name: Login to GitHub package registry
|
||||||
if: inputs.publish
|
if: inputs.publish
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Increase gradle daemon heap size
|
- name: Increase gradle daemon heap size
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ jobs:
|
||||||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
|
||||||
with:
|
with:
|
||||||
distribution: temurin
|
distribution: temurin
|
||||||
java-version: 17.0.6
|
java-version: 21
|
||||||
|
|
||||||
- name: Increase gradle daemon heap size
|
- name: Increase gradle daemon heap size
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ and discuss your ideas or propose the changes you wish to make.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
This project requires Java 17 to build and run tests. Newer JDK's may work, but this version is used in CI.
|
This project requires Java 21 to build and run tests. Newer JDK's may work, but this version is used in CI.
|
||||||
|
|
||||||
Some instrumentations and tests may put constraints on which java versions they support.
|
Some instrumentations and tests may put constraints on which java versions they support.
|
||||||
See [Running the tests](./docs/contributing/running-tests.md) for more details.
|
See [Running the tests](./docs/contributing/running-tests.md) for more details.
|
||||||
|
|
@ -22,7 +22,7 @@ the Sonatype OSS snapshots repository at `https://oss.sonatype.org/content/repos
|
||||||
|
|
||||||
### Building from source
|
### Building from source
|
||||||
|
|
||||||
Build using Java 17:
|
Build using Java 21:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
java -version
|
java -version
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import org.gradle.api.provider.Property
|
||||||
|
|
||||||
abstract class OtelJavaExtension {
|
abstract class OtelJavaExtension {
|
||||||
abstract val minJavaVersionSupported: Property<JavaVersion>
|
abstract val minJavaVersionSupported: Property<JavaVersion>
|
||||||
|
abstract val maxJavaVersionSupported: Property<JavaVersion>
|
||||||
|
|
||||||
abstract val maxJavaVersionForTests: Property<JavaVersion>
|
abstract val maxJavaVersionForTests: Property<JavaVersion>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,15 @@ afterEvaluate {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version to use to compile code and run tests.
|
// Version to use to compile code and run tests.
|
||||||
val DEFAULT_JAVA_VERSION = JavaVersion.VERSION_17
|
val DEFAULT_JAVA_VERSION = JavaVersion.VERSION_21
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion.set(
|
languageVersion.set(
|
||||||
otelJava.minJavaVersionSupported.map { JavaLanguageVersion.of(Math.max(it.majorVersion.toInt(), DEFAULT_JAVA_VERSION.majorVersion.toInt())) }
|
otelJava.minJavaVersionSupported.map {
|
||||||
|
val defaultJavaVersion = otelJava.maxJavaVersionSupported.getOrElse(DEFAULT_JAVA_VERSION).majorVersion.toInt()
|
||||||
|
JavaLanguageVersion.of(Math.max(it.majorVersion.toInt(), defaultJavaVersion))
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,11 +72,18 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
"-Xlint:-processing",
|
"-Xlint:-processing",
|
||||||
// We suppress the "options" warning because it prevents compilation on modern JDKs
|
// We suppress the "options" warning because it prevents compilation on modern JDKs
|
||||||
"-Xlint:-options",
|
"-Xlint:-options",
|
||||||
|
// jdk21 generates more serial warnings than previous versions
|
||||||
|
"-Xlint:-serial",
|
||||||
|
|
||||||
// Fail build on any warning
|
// Fail build on any warning
|
||||||
"-Werror"
|
"-Werror"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
val defaultJavaVersion = otelJava.maxJavaVersionSupported.getOrElse(DEFAULT_JAVA_VERSION).majorVersion.toInt()
|
||||||
|
if (Math.max(otelJava.minJavaVersionSupported.get().majorVersion.toInt(), defaultJavaVersion) >= 21) {
|
||||||
|
// new warning in jdk21
|
||||||
|
compilerArgs.add("-Xlint:-this-escape")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
encoding = "UTF-8"
|
encoding = "UTF-8"
|
||||||
|
|
@ -81,6 +91,11 @@ tasks.withType<JavaCompile>().configureEach {
|
||||||
if (name.contains("Test")) {
|
if (name.contains("Test")) {
|
||||||
// serialVersionUID is basically guaranteed to be useless in tests
|
// serialVersionUID is basically guaranteed to be useless in tests
|
||||||
compilerArgs.add("-Xlint:-serial")
|
compilerArgs.add("-Xlint:-serial")
|
||||||
|
// when code is compiled with jdk 21 and executed with jdk 8, the -parameters flag is needed to avoid
|
||||||
|
// java.lang.reflect.MalformedParametersException: Invalid parameter name ""
|
||||||
|
// when junit calls java.lang.reflect.Executable.getParameters() on the constructor of a
|
||||||
|
// non-static nested test class
|
||||||
|
compilerArgs.add("-parameters")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ tasks {
|
||||||
"--add-exports",
|
"--add-exports",
|
||||||
"jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
"jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||||
"--add-exports",
|
"--add-exports",
|
||||||
|
"jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
||||||
|
"--add-exports",
|
||||||
"jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
|
"jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
|
||||||
"--add-exports",
|
"--add-exports",
|
||||||
"jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
"jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,16 @@ plugins {
|
||||||
id("otel.java-conventions")
|
id("otel.java-conventions")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
compileJava {
|
||||||
|
// when code is compiled with jdk 21 and executed with jdk 8 -parameters flag is needed to avoid
|
||||||
|
// java.lang.reflect.MalformedParametersException: Invalid parameter name ""
|
||||||
|
// when junit calls java.lang.reflect.Executable.getParameters() on the constructor of a
|
||||||
|
// non-static nested test class
|
||||||
|
options.compilerArgs.add("-parameters")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":testing-common"))
|
api(project(":testing-common"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class SanitizationTest {
|
||||||
when(exchange.getIn()).thenReturn(message);
|
when(exchange.getIn()).thenReturn(message);
|
||||||
|
|
||||||
String actualSanitized = decorator.getStatement(exchange, null);
|
String actualSanitized = decorator.getStatement(exchange, null);
|
||||||
assertEquals(actualSanitized, expected);
|
assertEquals(expected, actualSanitized);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
|
@ -45,7 +45,7 @@ class SanitizationTest {
|
||||||
when(exchange.getIn()).thenReturn(message);
|
when(exchange.getIn()).thenReturn(message);
|
||||||
|
|
||||||
String actualSanitized = decorator.getStatement(exchange, null);
|
String actualSanitized = decorator.getStatement(exchange, null);
|
||||||
assertEquals(actualSanitized, expected);
|
assertEquals(expected, actualSanitized);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
|
@ -60,7 +60,7 @@ class SanitizationTest {
|
||||||
when(exchange.getIn()).thenReturn(message);
|
when(exchange.getIn()).thenReturn(message);
|
||||||
|
|
||||||
String actualSanitized = decorator.getStatement(exchange, null);
|
String actualSanitized = decorator.getStatement(exchange, null);
|
||||||
assertEquals(actualSanitized, expected);
|
assertEquals(expected, actualSanitized);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SqlArgs implements ArgumentsProvider {
|
static class SqlArgs implements ArgumentsProvider {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,13 @@ muzzle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (findProperty("testLatestDeps") as Boolean) {
|
||||||
|
// when running on jdk 21 Elasticsearch53SpringRepositoryTest occasionally fails with timeout
|
||||||
|
otelJava {
|
||||||
|
maxJavaVersionSupported.set(JavaVersion.VERSION_17)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.elasticsearch.client:transport:5.3.0") {
|
compileOnly("org.elasticsearch.client:transport:5.3.0") {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@ package io.opentelemetry.javaagent.instrumentation.executors;
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
|
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
|
||||||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
|
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -26,8 +24,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
|
||||||
import org.junit.jupiter.api.condition.JRE;
|
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
abstract class ExecutorInstrumentationTest<T extends ExecutorService>
|
abstract class ExecutorInstrumentationTest<T extends ExecutorService>
|
||||||
|
|
@ -51,24 +47,6 @@ abstract class ExecutorInstrumentationTest<T extends ExecutorService>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EnabledForJreRange(min = JRE.JAVA_21)
|
|
||||||
static class VirtualThreadExecutorTest extends ExecutorInstrumentationTest<ExecutorService> {
|
|
||||||
VirtualThreadExecutorTest() {
|
|
||||||
super(newVirtualThreadPerTaskExecutor());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ExecutorService newVirtualThreadPerTaskExecutor() {
|
|
||||||
Method newVirtualThreadPerTaskExecutor;
|
|
||||||
try {
|
|
||||||
newVirtualThreadPerTaskExecutor =
|
|
||||||
Executors.class.getMethod("newVirtualThreadPerTaskExecutor");
|
|
||||||
return (ExecutorService) newVirtualThreadPerTaskExecutor.invoke(null);
|
|
||||||
} catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
|
|
||||||
throw new IllegalStateException("Should not happen on Java 21+", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class WorkStealingPoolTest extends ExecutorInstrumentationTest<ExecutorService> {
|
static class WorkStealingPoolTest extends ExecutorInstrumentationTest<ExecutorService> {
|
||||||
public WorkStealingPoolTest() {
|
public WorkStealingPoolTest() {
|
||||||
super(Executors.newWorkStealingPool(2));
|
super(Executors.newWorkStealingPool(2));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
plugins {
|
||||||
|
id("otel.javaagent-testing")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testInstrumentation(project(":instrumentation:executors:javaagent"))
|
||||||
|
|
||||||
|
testCompileOnly(project(":instrumentation:executors:bootstrap"))
|
||||||
|
testImplementation(project(":instrumentation:executors:testing"))
|
||||||
|
}
|
||||||
|
|
||||||
|
otelJava {
|
||||||
|
minJavaVersionSupported.set(JavaVersion.VERSION_21)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test>().configureEach {
|
||||||
|
// needed for VirtualThreadTest
|
||||||
|
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
|
||||||
|
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.javaagent.instrumentation.executors;
|
||||||
|
|
||||||
|
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
|
||||||
|
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
|
|
||||||
|
class VirtualThreadExecutorTest
|
||||||
|
extends AbstractExecutorServiceTest<ExecutorService, JavaAsyncChild> {
|
||||||
|
|
||||||
|
@RegisterExtension
|
||||||
|
static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
|
||||||
|
|
||||||
|
VirtualThreadExecutorTest() {
|
||||||
|
super(Executors.newVirtualThreadPerTaskExecutor(), testing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JavaAsyncChild newTask(boolean doTraceableWork, boolean blockThread) {
|
||||||
|
return new JavaAsyncChild(doTraceableWork, blockThread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,21 +12,13 @@ import java.lang.reflect.Method;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.EnabledForJreRange;
|
|
||||||
import org.junit.jupiter.api.condition.JRE;
|
|
||||||
|
|
||||||
@EnabledForJreRange(min = JRE.JAVA_21)
|
|
||||||
class VirtualThreadTest {
|
class VirtualThreadTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDisableContextPropagation() throws Exception {
|
void testDisableContextPropagation() throws Exception {
|
||||||
TestRunnable testRunnable = new TestRunnable();
|
TestRunnable testRunnable = new TestRunnable();
|
||||||
// Thread.ofVirtual().start(testRunnable);
|
Thread thread = Thread.ofVirtual().start(testRunnable);
|
||||||
Method ofVirtualMethod = Thread.class.getMethod("ofVirtual");
|
|
||||||
Object virtualThreadBuilder = ofVirtualMethod.invoke(null);
|
|
||||||
Method startVirtualThread =
|
|
||||||
Class.forName("java.lang.Thread$Builder").getMethod("start", Runnable.class);
|
|
||||||
Thread thread = (Thread) startVirtualThread.invoke(virtualThreadBuilder, testRunnable);
|
|
||||||
thread.join();
|
thread.join();
|
||||||
|
|
||||||
assertThat(testRunnable.error).isNull();
|
assertThat(testRunnable.error).isNull();
|
||||||
|
|
@ -11,6 +11,7 @@ import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ForkJoinTask;
|
import java.util.concurrent.ForkJoinTask;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
final class JavaAsyncChild extends ForkJoinTask<Object> implements TestTask {
|
final class JavaAsyncChild extends ForkJoinTask<Object> implements TestTask {
|
||||||
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("test");
|
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("test");
|
||||||
|
|
||||||
|
|
@ -18,6 +18,10 @@ muzzle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
otelJava {
|
||||||
|
maxJavaVersionSupported.set(JavaVersion.VERSION_17)
|
||||||
|
}
|
||||||
|
|
||||||
val grailsVersion = "3.0.6" // first version that the tests pass on
|
val grailsVersion = "3.0.6" // first version that the tests pass on
|
||||||
val springBootVersion = "1.2.5.RELEASE"
|
val springBootVersion = "1.2.5.RELEASE"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ muzzle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
otelJava {
|
||||||
|
maxJavaVersionSupported.set(JavaVersion.VERSION_17)
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("dev.zio:zio_$scalaVersion:$zioVersion")
|
compileOnly("dev.zio:zio_$scalaVersion:$zioVersion")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -294,13 +294,19 @@ public final class ReferenceMatcher {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TypeDescription superType = null;
|
||||||
if (typeOnClasspath.getSuperClass() != null) {
|
if (typeOnClasspath.getSuperClass() != null) {
|
||||||
MethodDescription.InDefinedShape methodOnSupertype =
|
superType = typeOnClasspath.getSuperClass().asErasure();
|
||||||
findMethod(methodRef, typeOnClasspath.getSuperClass().asErasure());
|
} else if (!"java.lang.Object".equals(typeOnClasspath.getName())) {
|
||||||
|
superType = TypeDescription.ForLoadedType.of(Object.class);
|
||||||
|
}
|
||||||
|
if (superType != null) {
|
||||||
|
MethodDescription.InDefinedShape methodOnSupertype = findMethod(methodRef, superType);
|
||||||
if (methodOnSupertype != null) {
|
if (methodOnSupertype != null) {
|
||||||
return methodOnSupertype;
|
return methodOnSupertype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TypeDescription.Generic interfaceType : typeOnClasspath.getInterfaces()) {
|
for (TypeDescription.Generic interfaceType : typeOnClasspath.getInterfaces()) {
|
||||||
MethodDescription.InDefinedShape methodOnSupertype =
|
MethodDescription.InDefinedShape methodOnSupertype =
|
||||||
findMethod(methodRef, interfaceType.asErasure());
|
findMethod(methodRef, interfaceType.asErasure());
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,7 @@ include(":instrumentation:elasticsearch:elasticsearch-transport-common:javaagent
|
||||||
include(":instrumentation:elasticsearch:elasticsearch-transport-common:testing")
|
include(":instrumentation:elasticsearch:elasticsearch-transport-common:testing")
|
||||||
include(":instrumentation:executors:bootstrap")
|
include(":instrumentation:executors:bootstrap")
|
||||||
include(":instrumentation:executors:javaagent")
|
include(":instrumentation:executors:javaagent")
|
||||||
|
include(":instrumentation:executors:jdk21-testing")
|
||||||
include(":instrumentation:executors:testing")
|
include(":instrumentation:executors:testing")
|
||||||
include(":instrumentation:external-annotations:javaagent")
|
include(":instrumentation:external-annotations:javaagent")
|
||||||
include(":instrumentation:external-annotations:javaagent-unit-tests")
|
include(":instrumentation:external-annotations:javaagent-unit-tests")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue