From f0c22f32dd1493c03b01013ddac93e861902d153 Mon Sep 17 00:00:00 2001 From: AlexQin Date: Wed, 16 Feb 2022 18:09:09 +0800 Subject: [PATCH] Ignore the synthetic constructor created by the agent (#111) * Resolves #8532, ignored the synthetic constructor created by java agent Co-authored-by: qinjunjie --- CHANGES.md | 1 + .../spring/patch/AutowiredAnnotationProcessorInterceptor.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bc7ddff4e..5ff25011a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Release Notes. * Support Druid Connection pool metrics collecting. * Support HikariCP Connection pool metrics collecting. * Support Dbcp2 Connection pool metrics collecting. +* Ignore the synthetic constructor created by the agent in the Spring patch plugin. #### Documentation diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutowiredAnnotationProcessorInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutowiredAnnotationProcessorInterceptor.java index ac03a0b50..24b4bdd0d 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutowiredAnnotationProcessorInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/apache/skywalking/apm/plugin/spring/patch/AutowiredAnnotationProcessorInterceptor.java @@ -20,7 +20,6 @@ package org.apache.skywalking.apm.plugin.spring.patch; import java.lang.reflect.Constructor; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -72,7 +71,7 @@ public class AutowiredAnnotationProcessorInterceptor implements InstanceMethodsA Constructor[] rawConstructor = beanClass.getDeclaredConstructors(); List> candidateRawConstructors = new ArrayList>(); for (Constructor constructor : rawConstructor) { - if (!Modifier.isPrivate(constructor.getModifiers())) { + if (!constructor.isSynthetic()) { candidateRawConstructors.add(constructor); } }