{"record":{"id":"c2ca63e1ac1ad646","repo":"quarkusio/quarkus","slug":"content-must-not-be-null","errorCode":null,"errorMessage":"content must not be null","messagePattern":"content must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/EntityPartBuilderImpl.java","lineNumber":97,"sourceCode":"    public EntityPart.Builder headers(MultivaluedMap<String, String> newHeaders) throws IllegalArgumentException {\n        if (newHeaders == null) {\n            throw new IllegalArgumentException(\"newHeaders must not be null\");\n        }\n        this.headers = new QuarkusMultivaluedHashMap<>();\n        this.headers.putAll(newHeaders);\n        return this;\n    }\n\n    @Override\n    public EntityPart.Builder fileName(String fileName) throws IllegalArgumentException {\n        this.fileName = fileName;\n        return this;\n    }\n\n    @Override\n    public EntityPart.Builder content(InputStream content) throws IllegalArgumentException {\n        if (content == null) {\n            throw new IllegalArgumentException(\"content must not be null\");\n        }\n        this.content = content;\n        this.contentType = null;\n        this.contentGenericType = null;\n        return this;\n    }\n\n    @Override\n    public <T> EntityPart.Builder content(T content, Class<? extends T> type) throws IllegalArgumentException {\n        if (content == null) {\n            throw new IllegalArgumentException(\"content must not be null\");\n        }\n        if (type == null) {\n            throw new IllegalArgumentException(\"type must not be null\");\n        }\n        this.content = content;\n        this.contentType = type;\n        this.contentGenericType = type;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/EntityPartBuilderImpl.java#L79-L115","documentation":"IllegalArgumentException from EntityPartBuilderImpl.content: the entity part content InputStream passed by the caller is null. This is a null-guard on the builder API (same pattern as the adjacent newHeaders null check); the input at fault is the content argument.","triggerScenarios":"Calling partBuilder.content((InputStream) null), e.g. when a file/resource stream failed to open (getResourceAsStream returned null) and was passed through.","commonSituations":"ClassLoader.getResourceAsStream(...) returning null for a missing resource; a file upload input stream that was never initialized; null returned by a stream factory.","solutions":["Check the stream source before building: handle getResourceAsStream returning null with a clear error.","Use Objects.requireNonNull(content) at the call site to fail where the null originates.","Fix file path/resource name typos so the stream opens successfully.","If the part may be empty, pass an empty ByteArrayInputStream instead of null."],"exampleFix":"// before\nInputStream in = getClass().getResourceAsStream(path);\nbuilder.content(in); // null if resource missing\n\n// after\nInputStream in = getClass().getResourceAsStream(path);\nif (in == null) {\n    throw new IllegalStateException(\"Resource not found: \" + path);\n}\nbuilder.content(in);","handlingStrategy":"validation","validationCode":"InputStream in = getClass().getResourceAsStream(path);\nObjects.requireNonNull(in, \"Resource not found: \" + path);\nbuilder.content(in);","typeGuard":"InputStream requireStream(InputStream in, String what) {\n    if (in == null) throw new IllegalStateException(\"Missing stream for \" + what);\n    return in;\n}","tryCatchPattern":"try {\n    builder.content(stream);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Part content stream was null\", e);\n}","preventionTips":["Check getResourceAsStream results immediately at the lookup site.","Use ByteArrayInputStream.empty()/new byte[0] for intentionally empty parts.","Verify resource paths/classloader visibility in packaged artifacts."],"tags":["resteasy-reactive","jax-rs","multipart","entitypart","input-stream","null-argument"],"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-14T00:17:10.932Z"}