@@ -3,9 +3,6 @@ package datadog.trace.agent.test
33import datadog.trace.agent.tooling.HelperInjector
44import datadog.trace.agent.tooling.Utils
55import datadog.trace.test.util.DDSpecification
6- import net.bytebuddy.description.type.TypeDescription
7- import net.bytebuddy.dynamic.ClassFileLocator
8- import net.bytebuddy.dynamic.loading.ClassInjector
96
107import java.lang.ref.WeakReference
118import java.util.concurrent.atomic.AtomicReference
@@ -16,7 +13,6 @@ import static datadog.trace.test.util.GCUtils.awaitGC
1613class HelperInjectionTest extends DDSpecification {
1714 static final String HELPER_CLASS_NAME = ' datadog.trace.agent.test.HelperClass'
1815
19- // @Flaky("awaitGC usage is flaky")
2016 def " helpers injected to non-delegating classloader" () {
2117 setup :
2218 HelperInjector injector = new HelperInjector (false , " test" , HELPER_CLASS_NAME )
@@ -45,39 +41,4 @@ class HelperInjectionTest extends DDSpecification {
4541 then : " HelperInjector doesn't prevent it from being collected"
4642 null == ref. get()
4743 }
48-
49- // @Flaky("awaitGC usage is flaky")
50- def " check hard references on class injection" () {
51- setup :
52-
53- // Copied from HelperInjector:
54- final ClassFileLocator locator =
55- ClassFileLocator.ForClassLoader . of(Utils . getAgentClassLoader())
56- final byte [] classBytes = locator. locate(HELPER_CLASS_NAME ). resolve()
57- final TypeDescription typeDesc =
58- new TypeDescription.Latent (
59- HELPER_CLASS_NAME , 0 , null , Collections . < TypeDescription.Generic > emptyList())
60-
61- AtomicReference<URLClassLoader > emptyLoader = new AtomicReference<> (new URLClassLoader (new URL [0 ], (ClassLoader ) null ))
62- AtomicReference<ClassInjector > injector = new AtomicReference<> (new ClassInjector.UsingReflection (emptyLoader. get()))
63- injector. get(). inject([(typeDesc): classBytes])
64-
65- when :
66- def injectorRef = new WeakReference (injector. get())
67- injector. set(null )
68-
69- awaitGC(injectorRef)
70-
71- then :
72- null == injectorRef. get()
73-
74- when :
75- def loaderRef = new WeakReference (emptyLoader. get())
76- emptyLoader. set(null )
77-
78- awaitGC(loaderRef)
79-
80- then :
81- null == loaderRef. get()
82- }
8344}
0 commit comments