{"record":{"id":"ceb38638517f9b5e","repo":"quarkusio/quarkus","slug":"returning-size-of-a-downloaded-file-is-not-support","errorCode":null,"errorMessage":"returning size of a downloaded file is not supported","messagePattern":"returning size of a downloaded file is not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/FileDownloadImpl.java","lineNumber":40,"sourceCode":"    }\n\n    @Override\n    public Path filePath() {\n        try {\n            return file == null ? null : file.getFile().toPath();\n        } catch (IOException e) {\n            throw new IllegalArgumentException(\"Unable to provide file for download\", e);\n        }\n    }\n\n    @Override\n    public String fileName() {\n        return file.getFilename();\n    }\n\n    @Override\n    public long size() {\n        throw new UnsupportedOperationException(\"returning size of a downloaded file is not supported\");\n    }\n\n    @Override\n    public String contentType() {\n        return file.getContentType();\n    }\n\n    @Override\n    public String charSet() {\n        return file.getCharset().name();\n    }\n}\n","sourceCodeStart":22,"sourceCodeEnd":53,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/FileDownloadImpl.java#L22-L53","documentation":"FileDownloadImpl.size() unconditionally throws UnsupportedOperationException because the REST Easy Reactive client multipart download does not track the size of the downloaded file. The underlying FileUpload abstraction it wraps does not expose a reliable size, so the API surface exists for interface compatibility but is explicitly unsupported.","triggerScenarios":"Any call to size() on a FileDownload obtained from a multipart file download response — there are no conditions; it always throws.","commonSituations":"Porting code from other clients (e.g. RestEasy Classic or WebClient) that exposed download size, computing progress bars or disk space checks before writing, generic file-handling utilities that call size() on any FileDownload implementation.","solutions":["Determine size by calling Files.size(download.filePath()) after obtaining the Path","Read the Content-Length header from the response instead of the download object","Avoid size() entirely; stream the file and count bytes if needed"],"exampleFix":"// before\nlong len = download.size(); // always throws\n// after\nlong len = Files.size(download.filePath()); // or use the response Content-Length header","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"long size;\ntry {\n    size = download.size();\n} catch (UnsupportedOperationException e) {\n    size = Files.size(download.filePath()); // fallback\n}","preventionTips":["Never call size() on FileDownload in REST Easy Reactive; use Files.size(filePath())","Read Content-Length from the response headers when size is needed before consuming","Document this limitation when porting code from other HTTP clients"],"tags":["rest-client","multipart","file-download","unsupported-operation"],"backgroundTag":"unsupported-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"}