{"record":{"id":"f2248505004564bc","repo":"quarkusio/quarkus","slug":"compressed-and-uncompressed-cannot-be-both-decla","errorCode":null,"errorMessage":"@Compressed and @Uncompressed cannot be both declared on resource method %s declared on %s","messagePattern":"@Compressed and @Uncompressed cannot be both declared on resource method (.+?) declared on (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CompressionScanner.java","lineNumber":48,"sourceCode":"    public CompressionScanner(VertxHttpBuildTimeConfig httpBuildTimeConfig) {\n        this.httpBuildTimeConfig = httpBuildTimeConfig;\n    }\n\n    @Override\n    public List<HandlerChainCustomizer> scan(MethodInfo method, ClassInfo actualEndpointClass,\n            Map<String, Object> methodContext) {\n        if (!httpBuildTimeConfig.enableCompression()) {\n            return Collections.emptyList();\n        }\n\n        AnnotationStore annotationStore = (AnnotationStore) methodContext.get(EndpointIndexer.METHOD_CONTEXT_ANNOTATION_STORE);\n        HttpCompression compression = HttpCompression.UNDEFINED;\n        if (annotationStore.hasAnnotation(method, COMPRESSED)) {\n            compression = HttpCompression.ON;\n        }\n        if (annotationStore.hasAnnotation(method, UNCOMPRESSED)) {\n            if (compression == HttpCompression.ON) {\n                throw new IllegalStateException(\n                        String.format(\n                                \"@Compressed and @Uncompressed cannot be both declared on resource method %s declared on %s\",\n                                method, actualEndpointClass));\n            } else {\n                compression = HttpCompression.OFF;\n            }\n        }\n        if (compression == HttpCompression.OFF) {\n            // No action is needed because the \"Content-Encoding: identity\" header is set for every request if compression is enabled\n            return Collections.emptyList();\n        }\n        ResteasyReactiveCompressionHandler handler = new ResteasyReactiveCompressionHandler(\n                // Avoid using Set.copyOf() here as it creates SetN<E> with unstable iteration order.\n                // This leads to bytecode being unstable across builds. Prefer using HashSet wrapped\n                // in Collections.unmodifiableSet() instead.\n                Collections.unmodifiableSet(\n                        new HashSet<>(httpBuildTimeConfig.compressMediaTypes().orElse(Collections.emptyList()))));\n        handler.setCompression(compression);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CompressionScanner.java#L30-L66","documentation":"CompressionScanner inspects JAX-RS resource methods at build time to compute their HTTP compression setting from the Quarkus @Compressed and @Uncompressed annotations, which are mutually exclusive. If a single resource method is annotated with both, the scanner cannot decide the behavior and throws this IllegalStateException during deployment.","triggerScenarios":"Annotating the same resource method (in a class scanned as a REST endpoint) with both io.quarkus.resteasy.reactive.Compressed and Uncompressed, triggering RESTEasy Reactive server deployment scanning.","commonSituations":"Toggling compression during development and forgetting to remove the other annotation; inheriting/composing annotations from a meta-annotated custom annotation that carries both; merge conflicts adding both annotations.","solutions":["Remove one of the two annotations from the resource method, keeping only @Compressed or @Uncompressed.","If both were inherited via meta-annotations, split the custom annotation into two or drop one layer.","Let the method inherit class/global compression config (quarkus.resteasy reactive compression settings) by removing both annotations."],"exampleFix":"// before\n@Compressed\n@Uncompressed // conflict\n@GET\npublic String get() { ... }\n\n// after\n@Compressed\n@GET\npublic String get() { ... }","handlingStrategy":"validation","validationCode":"static void assertNotBoth(Method m) {\n    boolean compressed = m.isAnnotationPresent(Compressed.class);\n    boolean uncompressed = m.isAnnotationPresent(Uncompressed.class);\n    if (compressed && uncompressed)\n        throw new IllegalStateException(\"@Compressed and @Uncompressed cannot both be on \" + m);\n}","typeGuard":null,"tryCatchPattern":"// Fails during Quarkus augmentation, not at runtime; guard in a unit test:\ntry {\n    runAugmentation();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"cannot be both declared\")) {\n        log.error(\"Remove one of @Compressed/@Uncompressed: \" + e.getMessage());\n    }\n}","preventionTips":["Annotate a resource method with only one of @Compressed or @Uncompressed","When switching compression mode, delete the old annotation rather than commenting it out","Check meta-annotated custom annotations for conflicting nested annotations"],"tags":["resteasy-reactive","deployment","annotations","compression","build-time"],"backgroundTag":"conflicting-annotations","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}