Skip to content

Commit b4a852e

Browse files
fix instrumentation module not loading silently when duplicate helper classnames are detected.
issue #9752 introduced a check that prevents an instrumentation module from being loaded when duplicate helper classes are detected. Such a case may arise when a class is detected by muzzle as a helper class and at the same time it is registered in additionalHelperClasses. Before #9752, the module would properly load. The proposed change will allow the instrumentation to load and log a warning. While it may be true that this is actually an issue in the instrumentation module, such cases are not obvious to find, there are modules in the field that have stopped working because this change and the fix should not lead to unintended behavior as we can expect the bytecode of the duplicates to be identical.
1 parent 19e6f9c commit b4a852e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

muzzle/src/main/java/io/opentelemetry/javaagent/tooling/HelperInjector.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import static java.util.logging.Level.FINE;
99
import static java.util.logging.Level.SEVERE;
10+
import static java.util.logging.Level.WARNING;
1011

1112
import com.google.errorprone.annotations.CanIgnoreReturnValue;
1213
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
@@ -183,8 +184,11 @@ public DynamicType.Builder<?> transform(
183184
HelperClassDefinition::getClassName,
184185
helper -> () -> helper.getBytecode().getBytecode(),
185186
(a, b) -> {
186-
throw new IllegalStateException(
187-
"Duplicate classnames for helper class detected!");
187+
logger.log(
188+
WARNING,
189+
"Duplicate classname for helper class in module {0} detected",
190+
new Object[] {this.requestingName});
191+
return a;
188192
},
189193
LinkedHashMap::new));
190194

0 commit comments

Comments
 (0)