You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "sky-dawn (via GitHub)" <gi...@apache.org> on 2023/05/04 10:28:01 UTC

[GitHub] [skywalking-java] sky-dawn commented on a diff in pull request #524: Fix SQLServer write data intercept failure (#10741)

sky-dawn commented on code in PR #524:
URL: https://github.com/apache/skywalking-java/pull/524#discussion_r1184833773


##########
apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/apache/skywalking/apm/plugin/jdbc/JDBCPreparedStatementSetterInterceptor.java:
##########
@@ -24,13 +24,14 @@
 import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 public class JDBCPreparedStatementSetterInterceptor implements InstanceMethodsAroundInterceptor {
     @Override
     public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
         Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
         final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
-        if (statementEnhanceInfos != null) {
+        if (statementEnhanceInfos != null && Modifier.isPublic(method.getModifiers())) {

Review Comment:
   Do you mean don't change the interceptor code? 
   
   In general, non-public method is the underlying implementation, I think it need not to be intercept.
   So if I can change the PSSetterDefinitionOfJDBCInstrumentation code,like this:
   ```
   @Override
       public ElementMatcher<MethodDescription> getMethodsMatcher() {
           ElementMatcher.Junction<MethodDescription> matcher = none();
   
           // remove TRACE_SQL_PARAMETERS judgement for dynamic config
           final Set<String> setters = ignorable ? PS_IGNORABLE_SETTERS : PS_SETTERS;
           for (String setter : setters) {
               matcher = matcher.or(named(setter));
           }
   
           return matcher;
       }
   ```
   change `matcher = matcher.or(named(setter))` to `matcher = matcher.or(named(setter).and(isPublic()))`
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org