From 5e8921d6cb31f915b0ab7ea3301aba10a9cd533b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A3=AE=E6=A3=AE=E6=A3=AE?= <87176129+mycxu@users.noreply.github.com> Date: Sat, 2 Nov 2024 13:08:31 +0800 Subject: [PATCH] fix: master node distributes large file upload requests causing OOM (#310) --- .../jifa/server/service/impl/WorkerServiceImpl.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/org/eclipse/jifa/server/service/impl/WorkerServiceImpl.java b/server/src/main/java/org/eclipse/jifa/server/service/impl/WorkerServiceImpl.java index 9552f525..427570e6 100644 --- a/server/src/main/java/org/eclipse/jifa/server/service/impl/WorkerServiceImpl.java +++ b/server/src/main/java/org/eclipse/jifa/server/service/impl/WorkerServiceImpl.java @@ -211,14 +211,10 @@ public FileLocation decideLocationForNewFile(UserEntity user, FileType type) { @Override public long forwardUploadRequestToStaticWorker(StaticWorkerEntity worker, FileType type, MultipartFile file) throws Throwable { MultipartBodyBuilder builder = new MultipartBodyBuilder(); - try { - builder.part("file", new ByteArrayResource(file.getBytes())) - .filename(file.getOriginalFilename() != null ? file.getOriginalFilename() : Constant.DEFAULT_FILENAME) - .contentType(MediaType.APPLICATION_OCTET_STREAM); - builder.part("type", type.name()); - } catch (IOException e) { - throw new RuntimeException(e); - } + builder.part("file", file.getResource()) + .filename(file.getOriginalFilename() != null ? file.getOriginalFilename() : Constant.DEFAULT_FILENAME) + .contentType(MediaType.APPLICATION_OCTET_STREAM); + builder.part("type", type.name()); UriBuilder uriBuilder = new DefaultUriBuilderFactory().builder() .scheme("http")