{"record":{"id":"243a973326eea011","repo":"pinpoint-apm/pinpoint","slug":"skip-adding-interceptor-already-intercepted-meth","errorCode":null,"errorMessage":"Skip adding interceptor. 'already intercepted method' class={}, interceptor={}","messagePattern":"Skip adding interceptor\\. 'already intercepted method' class=(.+?), interceptor=(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMMethod.java","lineNumber":254,"sourceCode":"        final ScopeFactory scopeFactory = this.engineComponent.getScopeFactory();\n        final ScopeInfo scopeInfo = scopeFactory.newScopeInfo(pluginContext, interceptorClass, interceptorScope, executionPolicy);\n        return createInterceptor(interceptorClass, constructorArgs, scopeInfo);\n    }\n\n    private ASMInterceptorHolder createInterceptor(Class<? extends Interceptor> interceptorClass, Object[] constructorArgs, ScopeInfo scopeInfo) throws InstrumentException {\n        final ObjectBinderFactory objectBinderFactory = this.engineComponent.getObjectBinderFactory();\n        final AnnotatedInterceptorFactory factory = objectBinderFactory.newAnnotatedInterceptorFactory(this.pluginContext);\n        final InterceptorHolderIdGenerator interceptorHolderIdGenerator = engineComponent.getInterceptorHolderIdGenerator();\n        return ASMInterceptorHolder.create(interceptorHolderIdGenerator, declaringClass.getClassLoader(), factory, interceptorClass, constructorArgs, scopeInfo, descriptor);\n    }\n\n    private void addInterceptor0(Class<? extends Interceptor> interceptorClass, ASMInterceptorHolder interceptorHolder) throws InstrumentException {\n        Objects.requireNonNull(interceptorClass, \"interceptorClass\");\n\n        final InterceptorDefinition interceptorDefinition = this.engineComponent.createInterceptorDefinition(interceptorClass);\n        final CaptureType captureType = interceptorDefinition.getCaptureType();\n        if (this.methodNode.hasInterceptor()) {\n            logger.warn(\"Skip adding interceptor. 'already intercepted method' class={}, interceptor={}\", this.declaringClass.getName(), interceptorClass.getName());\n            return;\n        }\n\n        if (this.methodNode.isAbstract() || this.methodNode.isNative()) {\n            logger.info(\"Skip adding interceptor. 'abstract or native method' class={}, interceptor={}\", this.declaringClass.getName(), interceptorClass.getName());\n            return;\n        }\n\n        int apiId = 0;\n        final InterceptorType interceptorType = interceptorDefinition.getInterceptorType();\n        if (interceptorType == InterceptorType.API_ID_AWARE || interceptorType == InterceptorType.ASYNC_CONTEXT_API_ID_AWARE) {\n            apiId = this.engineComponent.cacheApi(this.descriptor);\n        }\n\n        if (interceptorType == InterceptorType.RESULT_REPLACE && !this.methodNode.hasObjectOrArrayReturnType()) {\n            // constructors and void/primitive returns have no reference return value to replace.\n            throw new InstrumentException(\"result-replace interceptor requires an object or array return type.\"\n                    + \" class=\" + this.declaringClass.getName() + \", method=\" + this.methodNode.getName() + this.methodNode.getDesc()","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMMethod.java#L236-L272","documentation":"ASMMethod.addInterceptor0 logs this and returns without throwing when the target method's ASM method node already has an interceptor attached. Pinpoint allows only one interceptor per method per weave, so a second addInterceptor/addScopedInterceptor request on the same method is silently skipped. It protects the transformed class from double-probing.","triggerScenarios":"Calling addInterceptor/addScopedInterceptor/addInterceptorInternal on a method that a previous interceptor (or another plugin/profile targeting the same method) has already instrumented; two plugins matching the same method; agent re-transform hitting an already-woven class.","commonSituations":"Overlapping service-type/plugin configurations where both match the same API; duplicate interceptor registration in custom plugins; re-attaching the agent or applying a transform twice to the same class.","solutions":["Check which interceptor was applied first; remove the duplicate registration or narrow the matching pointcut so only one interceptor targets the method.","If chaining is intended, use a scoped interceptor design that delegates instead of two independent interceptors on one method.","Verify plugins are not double-loaded (same plugin jar present twice in the plugin directory).","Treat this as an expected warn if a base profile already instrumented the method."],"exampleFix":"// before\nmethod.addScopedInterceptor( MyInterceptor.class, \"myTraceScope\" );\n// after\nif (!methodInfo.isIntercepted()) { // or ensure only one plugin registers this API\n    method.addScopedInterceptor( MyInterceptor.class, \"myTraceScope\" );\n}","handlingStrategy":"validation","validationCode":"if (methodNode.hasInterceptor()) {\n    logger.info(\"method already instrumented, skipping {}\", methodName);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { method.addScopedInterceptor(cls, scope); } catch (InstrumentException e) { log.warn(\"interceptor add failed for {}\", methodName, e); }","preventionTips":["Ensure each API method is matched by at most one plugin interceptor","Avoid shipping the same plugin jar twice","Design interceptors with scopes and delegation instead of stacking","Review plugin matching overlap at startup"],"tags":["instrumentation","interceptor","plugin","duplicate"],"backgroundTag":"duplicate-interceptor-registration","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}