Skip to content

Commit 94ef8fb

Browse files
committed
fix: prevent Shadow 9 from relocating logback descriptor in ClassicSdk appender suppression
The upgrade from Shadow 8 to Shadow 9 (via gradle-plugins 2.26.1-alpha) changed constant pool string scanning to be more aggressive. Shadow 9 now rewrites all UTF-8 string constants containing relocatable package names, not just class/type references. This caused the literal "(Lch/qos/logback/classic/spi/ILoggingEvent;)V" inside ApplicationInsightsAppenderClassVisitor to be relocated to a shadowed package path, so the descriptor check in visitMethod() never matched the actual user class. This left the Classic SDK logback appender running unsuppressed, producing duplicate MessageData (SourceType "LOGBack" alongside "Logger"). Replace the exact descriptor equality checks with a generic signature pattern match on the append method. This is safe because transform() already gates on the exact appender class name via UnshadedSdkPackageName.
1 parent 8e7fcd9 commit 94ef8fb

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/classicsdk/ApplicationInsightsAppenderClassFileTransformer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ public MethodVisitor visitMethod(
7272
@Nullable String signature,
7373
@Nullable String[] exceptions) {
7474
MethodVisitor mv = cw.visitMethod(access, name, descriptor, signature, exceptions);
75+
// match append(SomeLoggingEvent): the descriptor type-strings are not checked here
76+
// because Shadow relocates the "ch/qos/logback" literal, breaking the match at runtime;
77+
// class-name filtering in transform() already guarantees we are in the right class
7578
if (name.equals("append")
76-
&& (descriptor.equals("(Lch/qos/logback/classic/spi/ILoggingEvent;)V")
77-
|| descriptor.equals("(Lorg/apache/log4j/spi/LoggingEvent;)V")
78-
|| descriptor.equals("(Lorg/apache/logging/log4j/core/LogEvent;)V"))) {
79+
&& descriptor.startsWith("(L")
80+
&& descriptor.endsWith(";)V")) {
7981
// no-op the append() method
8082
mv.visitCode();
8183
mv.visitInsn(RETURN);

0 commit comments

Comments
 (0)