diff --git a/CHANGES.md b/CHANGES.md index 8275c7e0fa..0e7dd67ab7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ Release Notes. * Add async-profiler feature for performance analysis * Support db.instance tag,db.collection tag and AggregateOperation span for mongodb plugin(3.x/4.x) * Improve CustomizeConfiguration by avoiding repeatedly resolve file config +* Add empty judgment for constructorInterceptPoint All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/222?closed=1) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java index f38ddfc5a8..b595d89e92 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java @@ -112,17 +112,20 @@ protected DynamicType.Builder enhanceInstance(TypeDescription typeDescription */ if (existedConstructorInterceptPoint) { for (ConstructorInterceptPoint constructorInterceptPoint : constructorInterceptPoints) { + String constructorInterceptor = constructorInterceptPoint.getConstructorInterceptor(); + if (StringUtil.isEmpty(constructorInterceptor)) { + throw new EnhanceException("no InstanceConstructorInterceptor define to enhance class " + enhanceOriginClassName); + } if (isBootstrapInstrumentation()) { newClassBuilder = newClassBuilder.constructor(constructorInterceptPoint.getConstructorMatcher()) - .intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.withDefaultConfiguration() - .to(BootstrapInstrumentBoost - .forInternalDelegateClass(constructorInterceptPoint - .getConstructorInterceptor())))); + .intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.withDefaultConfiguration() + .to(BootstrapInstrumentBoost + .forInternalDelegateClass(constructorInterceptor)))); } else { newClassBuilder = newClassBuilder.constructor(constructorInterceptPoint.getConstructorMatcher()) - .intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.withDefaultConfiguration() - .to(new ConstructorInter(getPluginName(), constructorInterceptPoint - .getConstructorInterceptor(), classLoader), delegateNamingResolver.resolve(constructorInterceptPoint)))); + .intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.withDefaultConfiguration() + .to(new ConstructorInter(getPluginName(), constructorInterceptor, classLoader), + delegateNamingResolver.resolve(constructorInterceptPoint)))); } } }