You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/12/30 07:30:53 UTC

[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #6103: new future add witness method

kezhenxu94 commented on a change in pull request #6103:
URL: https://github.com/apache/skywalking/pull/6103#discussion_r549984178



##########
File path: CHANGES.md
##########
@@ -22,6 +22,7 @@ Release Notes.
 * Fix DataCarrier's `org.apache.skywalking.apm.commons.datacarrier.buffer.Buffer` implementation isn't activated in `IF_POSSIBLE` mode.
 * Fix ArrayBlockingQueueBuffer's useless `IF_POSSIBLE` mode list
 * Support building gRPC TLS channel but CA file is not required.
+* add witness method for plugin develop.

Review comment:
       Capitalize this sentence 

##########
File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java
##########
@@ -70,6 +75,25 @@
                 }
             }
         }
+        List<WitnessMethod> witnessMethods = witnessMethods();
+        if (!CollectionUtil.isEmpty(witnessMethods)) {
+            for (WitnessMethod witnessMethod : witnessMethods) {
+                TypePool.Resolution resolution = WitnessClassFinder.INSTANCE.getResolution(witnessMethod.declaringClassName, classLoader);
+                if (!resolution.isResolved()) {
+                    LOGGER.warn("enhance class {} by plugin {} is not working. Because declaringClass {} of the witness method is not existed.", transformClassName, interceptorDefineClassName, witnessMethod.declaringClassName);
+                    return null;
+                }
+                boolean empty = resolution.resolve()
+                        .getDeclaredMethods()
+                        .filter(witnessMethod.elementMatcher)
+                        .isEmpty();
+                if(empty){

Review comment:
       code style
   ```suggestion
                   if (empty) {
   ```

##########
File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/WitnessMethod.java
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.agent.core.plugin;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.StringJoiner;
+
+/**
+ * @author binglongli217932
+ * <a href="mailto:libinglong9@gmail.com">libinglong:libinglong9@gmail.com</a>
+ * @since 2020/12/30
+ */

Review comment:
       Remove this




----------------------------------------------------------------
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.

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