{"record":{"id":"3478c89f8c391026","repo":"quarkusio/quarkus","slug":"adding-content-to-multibytehttpdata-is-not-support","errorCode":null,"errorMessage":"adding content to MultiByteHttpData is not supported","messagePattern":"adding content to MultiByteHttpData is not supported","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/MultiByteHttpData.java","lineNumber":147,"sourceCode":"                        paused = false;\n                        resumption.run();\n                    }\n                });\n    }\n\n    void suspend(int awaitedBytes) {\n        this.awaitedBytes = awaitedBytes;\n        this.paused = true;\n    }\n\n    @Override\n    public void setContent(ByteBuf buffer) throws IOException {\n        throw new IllegalStateException(\"setting content of MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public void addContent(ByteBuf buffer, boolean last) throws IOException {\n        throw new IllegalStateException(\"adding content to MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public void setContent(File file) throws IOException {\n        throw new IllegalStateException(\"setting content of MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public void setContent(InputStream inputStream) throws IOException {\n        throw new IllegalStateException(\"setting content of MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public void delete() {\n        // do nothing\n    }\n\n    @Override","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/MultiByteHttpData.java#L129-L165","documentation":"addContent(ByteBuf, boolean) is the standard Netty incremental-content entry point for HttpData, but MultiByteHttpData receives bytes only from its internal Multi<Byte> subscription. Calling addContent breaks the streaming protocol (buffer accounting, suspend/resume, done flag), so the class unconditionally throws IllegalStateException.","triggerScenarios":"Invoking addContent(buffer, last) on a MultiByteHttpData, e.g. by Netty's default HttpPostRequestEncoder path or custom code that appends chunks to multipart parts.","commonSituations":"Using a generic Netty multipart encoder on RESTEasy Reactive client parts; code paths that branch on FileUpload but assume Netty's MemoryFileUpload semantics; migrating legacy client code that piped ByteBuf chunks into uploads.","solutions":["Do not call addContent; let the Multi<Byte> passed to the part constructor drive the data.","If you already have ByteBuf/byte[] chunks, convert them to a Multi<Byte> (e.g. Multi.createFrom().iterable of chunks) and pass it as the part body.","Use a non-streaming part (byte[], File, Path, InputStream-backed) when you don't need reactive streaming.","Ensure only PausableHttpPostRequestEncoder manipulates these parts; it never calls addContent."],"exampleFix":"// before\nhttpData.addContent(Unpooled.wrappedBuffer(chunk), false);\n// after\nMulti<Byte> body = Multi.createFrom().iterable(chunks) // List<byte[]>\n        .onItem().transformToMultiAndMerge(bytes -> Multi.createFrom().items(bytes));\n// pass `body` as the streaming part content instead","handlingStrategy":"validation","validationCode":"if (data instanceof MultiByteHttpData) {\n    throw new IllegalArgumentException(\"Do not call addContent on MultiByteHttpData; bytes come from its Multi<Byte>\");\n}\ndata.addContent(buf, last);","typeGuard":"boolean supportsAddContent(InterfaceHttpData data) {\n    return !(data instanceof MultiByteHttpData);\n}","tryCatchPattern":"try {\n    data.addContent(buf, last);\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"not supported\")) {\n        // feed chunks via a Multi<Byte> part instead\n    } else {\n        throw e;\n    }\n}","preventionTips":["Only PausableHttpPostRequestEncoder should drive MultiByteHttpData.","Convert ByteBuf chunk sources into Multi<Byte> part content.","Do not apply Netty's default HttpPostRequestEncoder path to these parts.","Type-check before incremental content mutation."],"tags":["multipart","unsupported-operation","resteasy-reactive","netty"],"backgroundTag":"unsupported-multipart-operation","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"}