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_r381049791
########## 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: Why? `instanceof` is still much much slower than instrumentation level match. ---------------------------------------------------------------- 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