8000 Ensure net.bytebuddy.raw is set to true when ConfigTransformSpockExte… · DataDog/dd-trace-java@c020225 · GitHub
[go: up one dir, main page]

Skip to content

Commit c020225

Browse files
mccullssezen-datadog
authored andcommitted
Ensure net.bytebuddy.raw is set to true when ConfigTransformSpockExtension is installed (#8728)
This matches the same setting used by AgentInstaller which avoids spurious test failures in agent-tooling, specifically TypeFactoryForkedTest. This requires raw-types enabled to match the behaviour when installing the tracer with -javaagent. Without this byte-buddy will use dufferent code paths involving generic checks, which can lead to test failures using recent versions of byte-buddy (specifically going between full and outline types, where outlines are always raw-types by their nature.) These failures would not happen when using -javaagent because AgentInstaller forces the use of the raw-types setting. ConfigTransformSpockExtension should therefore do the same. Note we can't set this property in TypeFactoryForkedTest because by then it is too late, byte-buddy is already confgured by ConfigTransformSpockExtension and the raw-types value cannot be changed.
1 parent 767540d commit c020225

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/bytebuddy/outline/TypeFactoryForkedTest.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package datadog.trace.agent.tooling.bytebuddy.outline
22

33
import datadog.trace.agent.tooling.bytebuddy.ClassFileLocators
44
import datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers
5+
import net.bytebuddy.description.type.TypeDescription
56
import spock.lang.Shared
67
import spock.lang.Specification
78

@@ -28,6 +29,9 @@ class TypeFactoryForkedTest extends Specification {
2829
def hasContextField = declaresContextField('java.lang.Runnable', 'java.lang.String')
2930

3031
def "can mix full types with outlines"() {
32+
expect:
33+
TypeDescription.AbstractBase.RAW_TYPES // this test relies on raw-types
34+
3135
when:
3236
def systemLoader = ClassLoader.systemClassLoader
3337
def systemLocator = ClassFileLocators.classFileLocator(systemLoader)

utils/test-utils/src/main/groovy/datadog/trace/test/util/ConfigTransformSpockExtension.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import static net.bytebuddy.matcher.ElementMatchers.none
1818
* Transforms the Config class to make its INSTANCE field non-final and volatile.
1919
*/
2020
class ConfigTransformSpockExtension implements IGlobalExtension {
21+
static {
22+
// same setting as AgentInstaller to avoid spurious agent-tooling test failures
23+
System.setProperty("net.bytebuddy.raw", "true")
24+
}
25+
2126
static final String INST_CONFIG = "datadog.trace.api.InstrumenterConfig"
2227
static final String CONFIG = "datadog.trace.api.Config"
2328

0 commit comments

Comments
 (0)
0