Class KeyHolder
- java.lang.Object
-
- io.opentelemetry.javaagent.instrumentation.api.undertow.KeyHolder
-
public final class KeyHolder extends Object
Undertow'sio.undertow.server.HttpServerExchangeusesio.undertow.util.AttachmentKeyas a key for storing arbitrary data. It usesIdentityHashMapand thus all keys are compared for equality by object reference. This means that we cannot hold an instance ofio.undertow.util.AttachmentKeyin a static field of the corresponding Tracer, as we usually do. Tracers are loaded into user's classloaders and thus it is totally possible to have several instances of tracers. Each of those instances will have a separate value in a static field andio.undertow.server.HttpServerExchangewill treat them as different keys then.That is why this class exists and resides in a separate package. This package is treated in a special way and is always loaded by bootstrap classloader. This makes sure that this class is available to all tracers from every classloader.
But at the same time, being loaded by bootstrap classloader, this class itself cannot initiate the loading of
io.undertow.util.AttachmentKeyclass. Class has to be loaded by any classloader that has it, e.g. by the classloader of a Tracer that uses this key holder. After that, all Tracers, loaded by all classloaders, will be able to use exactly the same sole instance of the key.
-
-
Field Detail
-
contextKeys
public static final ConcurrentMap<Class<?>,Object> contextKeys
-
-