{"record":{"id":"540ed6348b4b8264","repo":"quarkusio/quarkus","slug":"getting-all-the-contents-of-a-multibytehttpdata-is","errorCode":null,"errorMessage":"getting all the contents of a MultiByteHttpData is not supported","messagePattern":"getting all the contents of a 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":167,"sourceCode":"\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\n    public byte[] get() throws IOException {\n        throw new IllegalStateException(\"getting all the contents of a MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public ByteBuf getByteBuf() {\n        throw new IllegalStateException(\"getting all the contents of a MultiByteHttpData is not supported\");\n    }\n\n    /**\n     * check if it is possible to read the next chunk of data of a given size\n     *\n     * @param chunkSize amount of bytes\n     * @return true if the requested amount of bytes is ready to be read or the Multi is completed, i.e. there will be\n     *         no more bytes to read\n     */\n    public boolean isReady(int chunkSize) {\n        return done || buffer.readableBytes() >= chunkSize;\n    }\n","sourceCodeStart":149,"sourceCodeEnd":185,"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#L149-L185","documentation":"get() returns the entire part content as a byte[] in standard Netty HttpData. MultiByteHttpData is a streaming adapter whose buffer may not hold all bytes at once and which requests more data lazily from the upstream Multi; materializing the whole content would violate its design, so get() throws IllegalStateException.","triggerScenarios":"Calling get() on a MultiByteHttpData, e.g. from debugging/logging code, generic InterfaceHttpData processors, or a decoder that drains completed uploads into memory.","commonSituations":"Inspecting sent multipart bodies in tests or interceptors; post-request processing of response/file-upload structures that call get() uniformly; tools that snapshot multipart parts for retries.","solutions":["Read content incrementally via getChunk(int) only after isReady(chunkSize) returns true, as PausableHttpPostRequestEncoder does.","If you need full bytes, send a byte[]-based part instead of a Multi<Byte> streaming part.","Collect the upstream Multi<Byte> itself (e.g. Multi collect().in(byte[])) before sending rather than pulling from the adapter.","Do not write generic code that assumes get() is safe on every FileUpload; branch on the concrete type."],"exampleFix":"// before\nbyte[] all = multiByteHttpData.get();\n// after\nByteBuf chunk = multiByteHttpData.getChunk(BUFFER_SIZE); // after isReady(BUFFER_SIZE)\nbyte[] part = new byte[chunk.readableBytes()];\nchunk.readBytes(part);","handlingStrategy":"type-guard","validationCode":"byte[] safeGet(InterfaceHttpData data) {\n    if (data instanceof MultiByteHttpData) {\n        throw new IllegalArgumentException(\"Read streaming parts via getChunk(), not get()\");\n    }\n    return data.get();\n}","typeGuard":"boolean supportsFullGet(InterfaceHttpData data) {\n    return !(data instanceof MultiByteHttpData);\n}","tryCatchPattern":"try {\n    byte[] all = data.get();\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"not supported\")) {\n        // drain incrementally via isReady()/getChunk()\n    } else {\n        throw e;\n    }\n}","preventionTips":["Read streaming parts only via isReady(int)/getChunk(int).","Use byte[] parts if you need whole-content access.","Collect the source Multi<Byte> before sending if you need the full payload.","Don't assume get() works on every FileUpload implementation."],"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-12T22:17:10.623Z"}