{"record":{"id":"f172cceb4e17b252","repo":"quarkusio/quarkus","slug":"an-interceptor-method-cannot-be-marked-produces-o","errorCode":null,"errorMessage":"An interceptor method cannot be marked @Produces or @Disposes - ","messagePattern":"An interceptor method cannot be marked @Produces or @Disposes - ","errorType":"validation","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java","lineNumber":110,"sourceCode":"        AnnotationStore store = beanDeployment.getAnnotationStore();\n        List<MethodInfo> aroundInvokes = new ArrayList<>();\n        List<MethodInfo> aroundConstructs = new ArrayList<>();\n        List<MethodInfo> postConstructs = new ArrayList<>();\n        List<MethodInfo> preDestroys = new ArrayList<>();\n\n        List<MethodInfo> allMethods = new ArrayList<>();\n        ClassInfo aClass = target.asClass();\n        while (aClass != null) {\n            // Only one interceptor method of a given type may be declared on a given class\n            int aroundInvokesFound = 0, aroundConstructsFound = 0, postConstructsFound = 0, preDestroysFound = 0;\n\n            for (MethodInfo method : aClass.methods()) {\n                if (Modifier.isStatic(method.flags())) {\n                    continue;\n                }\n                if (store.hasAnnotation(method, DotNames.PRODUCES) || store.hasAnnotation(method, DotNames.DISPOSES)) {\n                    // according to spec, finding @Produces or @Disposes on a method is a DefinitionException\n                    throw new DefinitionException(\n                            \"An interceptor method cannot be marked @Produces or @Disposes - \" + method + \" in class: \"\n                                    + aClass);\n                }\n                if (store.hasAnnotation(method, DotNames.AROUND_INVOKE)) {\n                    addInterceptorMethod(allMethods, aroundInvokes, method, InterceptionType.AROUND_INVOKE,\n                            InterceptorPlacement.INTERCEPTOR_CLASS);\n                    if (++aroundInvokesFound > 1) {\n                        throw new DefinitionException(\n                                \"Multiple @AroundInvoke interceptor methods declared on class: \" + aClass);\n                    }\n                }\n                if (store.hasAnnotation(method, DotNames.AROUND_CONSTRUCT)) {\n                    addInterceptorMethod(allMethods, aroundConstructs, method, InterceptionType.AROUND_CONSTRUCT,\n                            InterceptorPlacement.INTERCEPTOR_CLASS);\n                    if (++aroundConstructsFound > 1) {\n                        throw new DefinitionException(\n                                \"Multiple @AroundConstruct interceptor methods declared on class: \" + aClass);\n                    }","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/InterceptorInfo.java#L92-L128","documentation":"Per the CDI spec, a method of an interceptor class must not be annotated @Produces or @Disposes; interceptors are not beans that can produce or dispose. ArC throws a DefinitionException at build time while scanning interceptor class methods.","triggerScenarios":"Declaring @Produces or @Disposes on any non-static method of a class registered as an interceptor (has @Interceptor / @AroundInvoke etc.); detected in the InterceptorInfo constructor.","commonSituations":"Putting producer/disposer utility methods inside an interceptor class; copy-pasting methods between a bean class and an interceptor class.","solutions":["Remove @Produces/@Disposes from the interceptor method","Move the producer/disposer logic into a separate non-interceptor bean class","Make the method static if it is a pure utility (static methods are skipped by the check)"],"exampleFix":"// before\n@Interceptor\npublic class LogInterceptor {\n    @Produces\n    String make() { return \"x\"; }\n}\n// after\n@Interceptor\npublic class LogInterceptor {\n    @AroundInvoke\n    Object log(InvocationContext ctx) throws Exception { return ctx.proceed(); }\n}","handlingStrategy":"validation","validationCode":"for (Method m : MyInterceptor.class.getDeclaredMethods()) {\n    if (java.lang.reflect.java.lang.reflect.Modifier.isStatic(m.getModifiers())) continue;\n    if (m.isAnnotationPresent(Produces.class) || java.util.Arrays.stream(m.getParameterAnnotations())\n        .flatMap(java.util.Arrays::stream).anyMatch(a -> a.annotationType().getSimpleName().equals(\"Disposes\"))) {\n        throw new IllegalStateException(\"@Produces/@Disposes in interceptor: \" + m);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Interceptor classes should contain only interception methods (@AroundInvoke, @AroundConstruct, callbacks)","Place producers and disposers in regular beans, never in interceptors"],"tags":["cdi","arc","interceptor","producer","disposer"],"backgroundTag":"interceptor-method-role-conflict","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}