{"record":{"id":"6f3a742e3456ea95","repo":"quarkusio/quarkus","slug":"renaming-destination-file-for-multibytehttpdata-is","errorCode":null,"errorMessage":"Renaming destination file for MultiByteHttpData is not supported","messagePattern":"Renaming destination file for 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":231,"sourceCode":"\n            toRead -= readBytes;\n        }\n        return result;\n    }\n\n    @Override\n    public String getString() {\n        throw new IllegalStateException(\"Reading MultiByteHttpData as String is not supported\");\n    }\n\n    @Override\n    public String getString(Charset encoding) {\n        throw new IllegalStateException(\"Reading MultiByteHttpData as String is not supported\");\n    }\n\n    @Override\n    public boolean renameTo(File dest) {\n        throw new IllegalStateException(\"Renaming destination file for MultiByteHttpData is not supported\");\n    }\n\n    @Override\n    public boolean isInMemory() {\n        return true;\n    }\n\n    @Override\n    public File getFile() {\n        return null;\n    }\n\n    @Override\n    public FileUpload copy() {\n        throw new IllegalStateException(\"Copying MultiByteHttpData is not supported\");\n    }\n\n    @Override","sourceCodeStart":213,"sourceCodeEnd":249,"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#L213-L249","documentation":"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.","triggerScenarios":"Calling renameTo(File) on a MultiByteHttpData, e.g. code that persists received/generated file uploads generically by renaming their backing files.","commonSituations":"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.","solutions":["If you need the content as a file, drain it with getChunk(int) (after isReady) and write the chunks to the destination file yourself.","Use a File/Path-based multipart part when you need file semantics (renameTo, getFile).","Never call renameTo on client-side streaming parts; treat it as an unsupported operation by contract.","Branch on the concrete InterfaceHttpData type before calling renameTo."],"exampleFix":"// before\nhttpData.renameTo(new File(\"/tmp/out.bin\"));\n// after\ntry (FileOutputStream out = new FileOutputStream(\"/tmp/out.bin\")) {\n    while (httpData.isReady(chunkSize)) {\n        ByteBuf chunk = httpData.getChunk(chunkSize);\n        out.write(chunk.array(), chunk.arrayOffset(), chunk.readableBytes());\n    }\n}","handlingStrategy":"type-guard","validationCode":"void safeRenameTo(InterfaceHttpData data, File dest) throws IOException {\n    if (data instanceof MultiByteHttpData) {\n        throw new IllegalArgumentException(\"Streaming parts have no backing file; drain via getChunk() to a file\");\n    }\n    data.renameTo(dest);\n}","typeGuard":"boolean hasBackingFile(InterfaceHttpData data) {\n    return !(data instanceof MultiByteHttpData) && data.getFile() != null;\n}","tryCatchPattern":"try {\n    data.renameTo(dest);\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"not supported\")) {\n        // write chunks from getChunk() to dest manually\n    } else {\n        throw e;\n    }\n}","preventionTips":["Remember isInMemory()==true does not imply file support.","Use File/Path parts when file operations (renameTo/getFile) are needed.","Drain streaming parts with isReady/getChunk to persist them.","Type-check before rename operations."],"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"}