{"record":{"id":"1fe53b583c61d1b8","repo":"quarkusio/quarkus","slug":"replacing-multibytehttpdata-is-not-supported","errorCode":null,"errorMessage":"Replacing MultiByteHttpData is not supported","messagePattern":"Replacing 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":261,"sourceCode":"\n    @Override\n    public FileUpload copy() {\n        throw new IllegalStateException(\"Copying MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public FileUpload duplicate() {\n        throw new IllegalStateException(\"Duplicating MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public FileUpload retainedDuplicate() {\n        throw new IllegalStateException(\"Duplicating MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public FileUpload replace(ByteBuf content) {\n        throw new IllegalStateException(\"Replacing MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public FileUpload retain(int increment) {\n        super.retain(increment);\n        return this;\n    }\n\n    @Override\n    public FileUpload retain() {\n        super.retain();\n        return this;\n    }\n\n    @Override\n    public FileUpload touch() {\n        touch(null);\n        return this;","sourceCodeStart":243,"sourceCodeEnd":279,"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#L243-L279","documentation":"replace(ByteBuf) on MultiByteHttpData throws IllegalStateException because replacing the content of a multi-buffer upload part with a single ByteBuf is not supported. It is an interface-required stub that always fails.","triggerScenarios":"Calling FileUpload.replace(ByteBuf) on a MultiByteHttpData instance, e.g. when rewriting part content before send.","commonSituations":"Transforming multipart content in client filters; code that swaps buffers on Netty HttpData objects assuming all implementations support replace.","solutions":["Build a new MultiByteHttpData (or another FileUpload implementation) with the new ByteBuf rather than replacing","Use single-buffer file data types that support replace if buffer swapping is required","Modify the part before it becomes a MultiByteHttpData (e.g. at the file/attribute stage)"],"exampleFix":"// before\nFileUpload replaced = fileUpload.replace(newContent);\n// after\nFileUpload replaced = new MultiByteHttpData(fileUpload.getName(), fileUpload.getFilename(), fileUpload.getContentType(), fileUpload.getCharset());\nreplaced.setContent(newContent);","handlingStrategy":"fallback","validationCode":"if (data instanceof MultiByteHttpData) { /* avoid replace() */ }","typeGuard":"boolean supportsReplace(InterfaceHttpData d) { return !(d instanceof MultiByteHttpData); }","tryCatchPattern":"try { return upload.replace(buf); } catch (IllegalStateException e) { return newUploadWith(buf); }","preventionTips":["Create a new FileUpload instance when content must change","Transform content before constructing the multipart part","Prefer immutable handling of multipart parts in filters"],"tags":["netty","multipart","unsupported-operation","resteasy-reactive"],"backgroundTag":"unsupported-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"}