quarkusio/quarkus · error · IllegalStateException

Replacing MultiByteHttpData is not supported

Error message

Replacing MultiByteHttpData is not supported

What it means

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.

Source

Thrown at independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/MultiByteHttpData.java:261

    @Override
    public FileUpload copy() {
        throw new IllegalStateException("Copying MultiByteHttpData is not supported");
    }

    @Override
    public FileUpload duplicate() {
        throw new IllegalStateException("Duplicating MultiByteHttpData is not supported");
    }

    @Override
    public FileUpload retainedDuplicate() {
        throw new IllegalStateException("Duplicating MultiByteHttpData is not supported");
    }

    @Override
    public FileUpload replace(ByteBuf content) {
        throw new IllegalStateException("Replacing MultiByteHttpData is not supported");
    }

    @Override
    public FileUpload retain(int increment) {
        super.retain(increment);
        return this;
    }

    @Override
    public FileUpload retain() {
        super.retain();
        return this;
    }

    @Override
    public FileUpload touch() {
        touch(null);
        return this;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Build a new MultiByteHttpData (or another FileUpload implementation) with the new ByteBuf rather than replacing
  2. Use single-buffer file data types that support replace if buffer swapping is required
  3. Modify the part before it becomes a MultiByteHttpData (e.g. at the file/attribute stage)

Example fix

// before
FileUpload replaced = fileUpload.replace(newContent);
// after
FileUpload replaced = new MultiByteHttpData(fileUpload.getName(), fileUpload.getFilename(), fileUpload.getContentType(), fileUpload.getCharset());
replaced.setContent(newContent);
Defensive patterns

Strategy: fallback

Validate before calling

if (data instanceof MultiByteHttpData) { /* avoid replace() */ }

Type guard

boolean supportsReplace(InterfaceHttpData d) { return !(d instanceof MultiByteHttpData); }

Try / catch

try { return upload.replace(buf); } catch (IllegalStateException e) { return newUploadWith(buf); }

Prevention

When it happens

Trigger: Calling FileUpload.replace(ByteBuf) on a MultiByteHttpData instance, e.g. when rewriting part content before send.

Common situations: Transforming multipart content in client filters; code that swaps buffers on Netty HttpData objects assuming all implementations support replace.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/1fe53b583c61d1b8. Report an issue: GitHub.