{"record":{"id":"f57dd074af3fbd12","repo":"quarkusio/quarkus","slug":"compression-cannot-be-null","errorCode":null,"errorMessage":"Compression cannot be null","messagePattern":"Compression cannot be null","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/CompressionInterceptor.java","lineNumber":14,"sourceCode":"package io.quarkus.grpc.runtime.supports;\n\nimport io.grpc.Metadata;\nimport io.grpc.ServerCall;\nimport io.grpc.ServerCallHandler;\nimport io.grpc.ServerInterceptor;\n\npublic class CompressionInterceptor implements ServerInterceptor {\n\n    private final String compression;\n\n    public CompressionInterceptor(String compression) {\n        if (compression == null) {\n            throw new NullPointerException(\"Compression cannot be null\");\n        }\n        this.compression = compression;\n    }\n\n    @Override\n    public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(\n            ServerCall<ReqT, RespT> call,\n            Metadata headers,\n            ServerCallHandler<ReqT, RespT> next) {\n        call.setCompression(compression);\n        return next.startCall(call, headers);\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/CompressionInterceptor.java#L1-L28","documentation":"CompressionInterceptor wraps a gRPC server interceptor that applies a specific compression to responses. It validates in its constructor that the compression algorithm name is non-null, throwing NullPointerException otherwise. A null means the compression config was not resolved before constructing the interceptor.","triggerScenarios":"Constructing new CompressionInterceptor(null) directly, or a server configuration path that passes a null compression value into the interceptor.","commonSituations":"Custom server interceptor registration with an unresolved config property; reflection-based instantiation bypassing config defaults.","solutions":["Pass a valid, non-null compression algorithm name such as \"gzip\" or \"identity\"","Check the configuration source that supplies the compression value and add a default","Ensure the compression algorithm is registered (e.g. via Codec) before using it"],"exampleFix":"// before\nnew CompressionInterceptor(config.compression()); // null\n// after\nString c = config.compression() != null ? config.compression() : \"gzip\";\nnew CompressionInterceptor(c);","handlingStrategy":"validation","validationCode":"if (compression == null || compression.isBlank()) {\n    throw new IllegalArgumentException(\"compression must be set (e.g. gzip, identity)\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    new CompressionInterceptor(cfg.compression());\n} catch (NullPointerException e) {\n    LOG.warn(\"Compression unset; falling back to gzip\");\n}","preventionTips":["Default compression values in config","Never construct interceptors with raw nullable config values","Validate config at startup"],"tags":["grpc","null-pointer","compression","quarkus"],"backgroundTag":"null-required-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}