This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new d12d3f2  add redefine listener (#6309)
d12d3f2 is described below

commit d12d3f201a315241bd7aeb5cc97c2d5103e67c02
Author: libinglong <[email protected]>
AuthorDate: Wed Feb 3 16:27:06 2021 +0800

    add redefine listener (#6309)
---
 CHANGES.md                                         |  2 ++
 .../skywalking/apm/agent/SkyWalkingAgent.java      | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/CHANGES.md b/CHANGES.md
index 5086b4a..313e778 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,6 +9,8 @@ Release Notes.
 
 #### Java Agent
 * Remove invalid mysql configuration in agent.config.
+* Add net.bytebuddy.agent.builder.AgentBuilder.RedefinitionStrategy.Listener 
+  to show detail message when redifine errors occur
 
 
 #### OAP-Backend
diff --git 
a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
 
b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
index b327089..8fe9330 100644
--- 
a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
+++ 
b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java
@@ -19,7 +19,9 @@
 package org.apache.skywalking.apm.agent;
 
 import java.lang.instrument.Instrumentation;
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 import net.bytebuddy.ByteBuddy;
 import net.bytebuddy.agent.builder.AgentBuilder;
@@ -123,6 +125,7 @@ public class SkyWalkingAgent {
         agentBuilder.type(pluginFinder.buildMatch())
                     .transform(new Transformer(pluginFinder))
                     .with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
+                    .with(new RedefinitionListener())
                     .with(new Listener())
                     .installOn(instrumentation);
 
@@ -215,4 +218,23 @@ public class SkyWalkingAgent {
         public void onComplete(String typeName, ClassLoader classLoader, 
JavaModule module, boolean loaded) {
         }
     }
+
+    private static class RedefinitionListener implements 
AgentBuilder.RedefinitionStrategy.Listener {
+
+        @Override
+        public void onBatch(int index, List<Class<?>> batch, List<Class<?>> 
types) {
+            /* do nothing */
+        }
+
+        @Override
+        public Iterable<? extends List<Class<?>>> onError(int index, 
List<Class<?>> batch, Throwable throwable, List<Class<?>> types) {
+            LOGGER.error(throwable, "index={}, batch={}, types={}", index, 
batch, types);
+            return Collections.emptyList();
+        }
+
+        @Override
+        public void onComplete(int amount, List<Class<?>> types, 
Map<List<Class<?>>, Throwable> failures) {
+            /* do nothing */
+        }
+    }
 }

Reply via email to