wu-sheng commented on a change in pull request #4379: Fix ehcache:  missing 
interceptor of private constructor and setName method
URL: https://github.com/apache/skywalking/pull/4379#discussion_r381014400
 
 

 ##########
 File path: 
apm-sniffer/apm-sdk-plugin/ehcache-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/ehcache/v2/EhcacheConstructorInterceptor.java
 ##########
 @@ -18,18 +18,28 @@
 
 package org.apache.skywalking.apm.plugin.ehcache.v2;
 
+import net.sf.ehcache.Cache;
 import net.sf.ehcache.config.CacheConfiguration;
 import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
 import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
 
 public class EhcacheConstructorInterceptor implements 
InstanceConstructorInterceptor {
     @Override
     public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
-        CacheConfiguration cacheConfiguration = (CacheConfiguration) 
allArguments[0];
+        try {
+            CacheConfiguration cacheConfiguration = (CacheConfiguration) 
allArguments[0];
 
-        // get cache name
-        if (cacheConfiguration != null) {
-            objInst.setSkyWalkingDynamicField(new 
EhcacheEnhanceInfo(cacheConfiguration.getName()));
+            // get cache name
+            if (cacheConfiguration != null) {
+                objInst.setSkyWalkingDynamicField(new 
EhcacheEnhanceInfo(cacheConfiguration.getName()));
+            }
+        } catch (ClassCastException e) {
 
 Review comment:
   You don't need to use this `try/catch`. `getConstructorsInterceptPoints` 
returns an array, you should set up the interceptors separately. This one you 
didi has a performance issue.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to