quarkusio/quarkus · error · IllegalStateException

Renaming destination file for MultiByteHttpData is not suppo

Error message

Renaming destination file for MultiByteHttpData is not supported

What it means

renameTo(File) moves a disk-backed Netty HttpData's file to a destination. MultiByteHttpData never touches the filesystem - it streams bytes from a Multi<Byte> entirely in memory buffers - so there is no file to rename and it always throws IllegalStateException.

Source

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

            toRead -= readBytes;
        }
        return result;
    }

    @Override
    public String getString() {
        throw new IllegalStateException("Reading MultiByteHttpData as String is not supported");
    }

    @Override
    public String getString(Charset encoding) {
        throw new IllegalStateException("Reading MultiByteHttpData as String is not supported");
    }

    @Override
    public boolean renameTo(File dest) {
        throw new IllegalStateException("Renaming destination file for MultiByteHttpData is not supported");
    }

    @Override
    public boolean isInMemory() {
        return true;
    }

    @Override
    public File getFile() {
        return null;
    }

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

    @Override

View on GitHub (pinned to e1c734241f)

Solutions

  1. If you need the content as a file, drain it with getChunk(int) (after isReady) and write the chunks to the destination file yourself.
  2. Use a File/Path-based multipart part when you need file semantics (renameTo, getFile).
  3. Never call renameTo on client-side streaming parts; treat it as an unsupported operation by contract.
  4. Branch on the concrete InterfaceHttpData type before calling renameTo.

Example fix

// before
httpData.renameTo(new File("/tmp/out.bin"));
// after
try (FileOutputStream out = new FileOutputStream("/tmp/out.bin")) {
    while (httpData.isReady(chunkSize)) {
        ByteBuf chunk = httpData.getChunk(chunkSize);
        out.write(chunk.array(), chunk.arrayOffset(), chunk.readableBytes());
    }
}
Defensive patterns

Strategy: type-guard

Validate before calling

void safeRenameTo(InterfaceHttpData data, File dest) throws IOException {
    if (data instanceof MultiByteHttpData) {
        throw new IllegalArgumentException("Streaming parts have no backing file; drain via getChunk() to a file");
    }
    data.renameTo(dest);
}

Type guard

boolean hasBackingFile(InterfaceHttpData data) {
    return !(data instanceof MultiByteHttpData) && data.getFile() != null;
}

Try / catch

try {
    data.renameTo(dest);
} catch (IllegalStateException e) {
    if (e.getMessage() != null && e.getMessage().contains("not supported")) {
        // write chunks from getChunk() to dest manually
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling renameTo(File) on a MultiByteHttpData, e.g. code that persists received/generated file uploads generically by renaming their backing files.

Common situations: Server-side upload-handling patterns (rename temp file to final location) reused against client multipart parts; cleanup/persistence utilities iterating InterfaceHttpData objects; code assuming isInMemory()==true implies file support.

Related errors


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