Skip to content

Commit cb764a7

Browse files
Add empty judgment for constructorInterceptPoint (#732)
1 parent 2059fd4 commit cb764a7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Release Notes.
1212
* Add async-profiler feature for performance analysis
1313
* Support db.instance tag,db.collection tag and AggregateOperation span for mongodb plugin(3.x/4.x)
1414
* Improve CustomizeConfiguration by avoiding repeatedly resolve file config
15+
* Add empty judgment for constructorInterceptPoint
1516

1617
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/222?closed=1)
1718

apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,20 @@ protected DynamicType.Builder<?> enhanceInstance(TypeDescription typeDescription
112112
*/
113113
if (existedConstructorInterceptPoint) {
114114
for (ConstructorInterceptPoint constructorInterceptPoint : constructorInterceptPoints) {
115+
String constructorInterceptor = constructorInterceptPoint.getConstructorInterceptor();
116+
if (StringUtil.isEmpty(constructorInterceptor)) {
117+
throw new EnhanceException("no InstanceConstructorInterceptor define to enhance class " + enhanceOriginClassName);
118+
}
115119
if (isBootstrapInstrumentation()) {
116120
newClassBuilder = newClassBuilder.constructor(constructorInterceptPoint.getConstructorMatcher())
117-
.intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.withDefaultConfiguration()
118-
.to(BootstrapInstrumentBoost
119-
.forInternalDelegateClass(constructorInterceptPoint
120-
.getConstructorInterceptor()))));
121+
.intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.withDefaultConfiguration()
122+
.to(BootstrapInstrumentBoost
123+
.forInternalDelegateClass(constructorInterceptor))));
121124
} else {
122125
newClassBuilder = newClassBuilder.constructor(constructorInterceptPoint.getConstructorMatcher())
123-
.intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.withDefaultConfiguration()
124-
.to(new ConstructorInter(getPluginName(), constructorInterceptPoint
125-
.getConstructorInterceptor(), classLoader), delegateNamingResolver.resolve(constructorInterceptPoint))));
126+
.intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.withDefaultConfiguration()
127+
.to(new ConstructorInter(getPluginName(), constructorInterceptor, classLoader),
128+
delegateNamingResolver.resolve(constructorInterceptPoint))));
126129
}
127130
}
128131
}

0 commit comments

Comments
 (0)