{"record":{"id":"6601c7a28c910438","repo":"quarkusio/quarkus","slug":"decorator-declares-an-async-observer-method-dec","errorCode":null,"errorMessage":"Decorator declares an async observer method: ${decoratorClass}","messagePattern":"Decorator declares an async observer method: (.+?)","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Decorators.java","lineNumber":174,"sourceCode":"                decoratedTypes, injections, priority);\n    }\n\n    private static void checkDecoratorFieldsAndMethods(ClassInfo decoratorClass, BeanDeployment beanDeployment) {\n        ClassInfo aClass = decoratorClass;\n        while (aClass != null) {\n            for (MethodInfo method : aClass.methods()) {\n                if (beanDeployment.hasAnnotation(method, DotNames.PRODUCES)) {\n                    throw new DefinitionException(\"Decorator declares a producer method: \" + decoratorClass);\n                }\n                // the following 3 checks rely on the annotation store returning parameter annotations for methods\n                if (beanDeployment.hasAnnotation(method, DotNames.DISPOSES)) {\n                    throw new DefinitionException(\"Decorator declares a disposer method: \" + decoratorClass);\n                }\n                if (beanDeployment.hasAnnotation(method, DotNames.OBSERVES)) {\n                    throw new DefinitionException(\"Decorator declares an observer method: \" + decoratorClass);\n                }\n                if (beanDeployment.hasAnnotation(method, DotNames.OBSERVES_ASYNC)) {\n                    throw new DefinitionException(\"Decorator declares an async observer method: \" + decoratorClass);\n                }\n            }\n\n            for (FieldInfo field : aClass.fields()) {\n                if (beanDeployment.hasAnnotation(field, DotNames.PRODUCES)) {\n                    throw new DefinitionException(\"Decorator declares a producer field: \" + decoratorClass);\n                }\n            }\n\n            DotName superClass = aClass.superName();\n            aClass = superClass != null && !superClass.equals(DotNames.OBJECT)\n                    ? getClassByName(beanDeployment.getBeanArchiveIndex(), superClass)\n                    : null;\n        }\n    }\n\n}\n","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Decorators.java#L156-L192","documentation":"Build-time CDI definition error: a method in the decorator's class hierarchy has an @ObservesAsync parameter. Async observers are not allowed on decorators; ArC rejects the bean deployment naming the offending decorator class.","triggerScenarios":"A @Decorator class declares a method with an @ObservesAsync-annotated parameter, found by checkDecoratorFieldsAndMethods.","commonSituations":"Reactive refactor adding async observers onto a decorator; leftover @ObservesAsync after a class became a decorator; copying an async observer into the decorator.","solutions":["Remove the @ObservesAsync method from the decorator.","Move async observation to a dedicated observer bean.","Keep the decorator focused on decorating the target interface only.","Verify superclasses, as the validation includes inherited methods."],"exampleFix":"// before\n@Decorator\npublic class D implements Greeter {\n    void onTick(@ObservesAsync TickEvent e) { }\n}\n\n// after\n@Decorator\npublic class D implements Greeter { /* observer moved out */ }","handlingStrategy":"validation","validationCode":"if (decoratorClass.getAnnotation(jakarta.decorator.Decorator.class) != null)\n    for (Method m : decoratorClass.getMethods())\n        if (m.isAnnotationPresent(jakarta.enterprise.event.ObservesAsync.class))\n            throw new IllegalStateException(\"Decorator cannot declare async observer: \" + m);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Move @ObservesAsync methods into dedicated observer beans.","Audit decorators during reactive refactors for stray observer annotations."],"tags":["cdi","decorator","observer","async","illegal-annotation"],"backgroundTag":"illegal-annotation-on-decorator","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"}