Skip to content

Commit 66fa381

Browse files
committed
spotless + javadoc
1 parent 0eda2c4 commit 66fa381

2 files changed

Lines changed: 30 additions & 16 deletions

File tree

javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/indy/IndyModuleRegistry.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ private IndyModuleRegistry() {}
2727

2828
/**
2929
* Weakly references the {@link InstrumentationModuleClassLoader}s for a given application class
30-
* loader. The {@link InstrumentationModuleClassLoader} are kept alive by a strong reference from
31-
* the instrumented class loader realized via {@link ClassLoaderValue}.
32-
*
33-
* <p>The keys of the contained map are the instrumentation module group names, see {@link
34-
* ExperimentalInstrumentationModule#getModuleGroup()};
30+
* loader for the internal instrumentation. The {@link InstrumentationModuleClassLoader} are kept
31+
* alive by a strong reference from the instrumented class loader realized via {@link
32+
* ClassLoaderValue}.
3533
*/
3634
private static final ClassLoaderValue<InstrumentationModuleClassLoader>
3735
instrumentationClassLoaders = new ClassLoaderValue<>();
3836

39-
private static final ClassLoaderValue<Map<ClassLoader, InstrumentationModuleClassLoader>> extensionClassLoaders =
40-
new ClassLoaderValue<>();
37+
/**
38+
* Weakly references the {@link InstrumentationModuleClassLoader}s for a given extension class
39+
* loader with application class loader as key. The {@link InstrumentationModuleClassLoader} are
40+
* kept alive by a strong reference from the instrumented class loader realized via {@link
41+
* ClassLoaderValue}.
42+
*/
43+
private static final ClassLoaderValue<Map<ClassLoader, InstrumentationModuleClassLoader>>
44+
extensionsInstrumentationClassLoaders = new ClassLoaderValue<>();
4145

4246
public static InstrumentationModuleClassLoader getInstrumentationClassLoader(
4347
String moduleClassName, ClassLoader instrumentedClassLoader) {
@@ -117,17 +121,23 @@ private static void initializeModuleLoaderForClassLoader(
117121
InstrumentationModule module, ClassLoader classLoader) {
118122

119123
ClassLoader agentOrExtensionCl = module.getClass().getClassLoader();
120-
InstrumentationModuleClassLoader moduleCl = null;
121-
if(!(agentOrExtensionCl instanceof ExtensionClassLoader)){
122-
// non-extension modules are loaded in a common InstrumentationModuleClassLoader per instrumented CL
123-
moduleCl = instrumentationClassLoaders.computeIfAbsent(
124+
InstrumentationModuleClassLoader moduleCl;
125+
if (!(agentOrExtensionCl instanceof ExtensionClassLoader)) {
126+
// non-extension modules are loaded in a common InstrumentationModuleClassLoader per
127+
// instrumented CL
128+
moduleCl =
129+
instrumentationClassLoaders.computeIfAbsent(
124130
classLoader,
125131
() -> new InstrumentationModuleClassLoader(classLoader, agentOrExtensionCl));
126132
} else {
127-
// extension modules are loaded in a common InstrumentationModuleCLassLoader per extension and instrumented CL
128-
moduleCl = extensionClassLoaders
129-
.computeIfAbsent(agentOrExtensionCl, HashMap::new)
130-
.computeIfAbsent(classLoader, k -> new InstrumentationModuleClassLoader(classLoader, agentOrExtensionCl));
133+
// extension modules are loaded in a common InstrumentationModuleCLassLoader per extension and
134+
// instrumented CL
135+
moduleCl =
136+
extensionsInstrumentationClassLoaders
137+
.computeIfAbsent(agentOrExtensionCl, HashMap::new)
138+
.computeIfAbsent(
139+
classLoader,
140+
k -> new InstrumentationModuleClassLoader(classLoader, agentOrExtensionCl));
131141
}
132142

133143
moduleCl.installModule(module);

javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/instrumentation/indy/InstrumentationModuleClassLoader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ synchronized void installModule(InstrumentationModule module, boolean forMuzzleC
151151
ClassLoader moduleCl = module.getClass().getClassLoader();
152152
if (moduleCl != agentOrExtensionCl) {
153153
throw new IllegalArgumentException(
154-
module.getClass().getName() + " is not loaded by " + agentOrExtensionCl+" but is loaded by "+moduleCl);
154+
module.getClass().getName()
155+
+ " is not loaded by "
156+
+ agentOrExtensionCl
157+
+ " but is loaded by "
158+
+ moduleCl);
155159
}
156160
if (!installedModules.add(module)) {
157161
return;

0 commit comments

Comments
 (0)