{"id":467950,"date":"2025-07-20T22:12:55","date_gmt":"2025-07-20T22:12:55","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=467950"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=467950","title":{"rendered":"<span>Spring boot, \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043a\u0430 \u0438 \u043c\u0430\u0433\u0438\u044f \u0432\u043d\u0435 \u0445\u043e\u0433\u0432\u0430\u0440\u0442\u0441\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0435\u0439, \u0438 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e Java\u2011\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0441 2018 \u0433\u043e\u0434\u0430. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <code>MultipartFile<\/code> \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0438 \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442.<\/p>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u044f\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u043d\u043e\u0432\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 Excel-\u0444\u0430\u0439\u043b\u043e\u0432: \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 HTTP-200 (\u0431\u0435\u0437 \u0434\u0430\u043d\u043d\u044b\u0445), \u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435.<\/p>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0430 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f. \u0414\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<pre><code>@RestController @RequestMapping public class FileController {      private final FileService fileService;      @Autowired     public FileController(FileService fileService) {         this.fileService = fileService;     }      @PostMapping(value = \"\/upload-from-files\", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)     public ResponseEntity&lt;Void&gt; saveFromFiles(@RequestPart(value = \"files\", required = false) List&lt;MultipartFile&gt; files) {         fileService.parseValuesFromFileToDTO(files);         return new ResponseEntity&lt;&gt;(HttpStatus.OK);     } }<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>CompletableFuture<\/code>, \u0447\u0442\u043e\u0431\u044b \u0440\u0443\u043a\u0430\u043c\u0438 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0438.<\/p>\n<pre><code>@Service public class FileService {     static final Logger log = LoggerFactory.getLogger(FileService.class);     public void parseValuesFromFileToDTO(List&lt;MultipartFile&gt; files) {         CompletableFuture&lt;Void&gt; filesDtoFromFile = CompletableFuture.runAsync(() -&gt;         {             for(MultipartFile file : files) {                 final Integer cellIndex = 0;                 final Integer sheetIndex = 0;                 final Integer limitValues = 100;                 try {                     Set&lt;String&gt; emailsFromFile = parseCellValueByCellIndexAndSheetIndexWithLimitValues(cellIndex,                             sheetIndex,                             limitValues,                             file.getBytes());                     for (String email:emailsFromFile) {                         log.info(email);                     }                 } catch (IOException e) {                     throw new RuntimeException(e);                 }             }          }, Executors.newSingleThreadExecutor()).exceptionally((e) -&gt; {             log.error(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432)\", e);             return null;         });         filesDtoFromFile.thenRun(() -&gt; log.info(\"\u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432) \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e\"));     }      \/***      * \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u0430 \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439      *      * @param cellIndex  - \u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0444\u0430\u0439\u043b\u0430.      * @param sheetIndex - \u0438\u043d\u0434\u0435\u043a\u0441 \u043b\u0438\u0441\u0442\u0430 \u0444\u0430\u0439\u043b\u0430.      * @param limit      - \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.      *      * @return \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430.      *\/     public static Set&lt;String&gt; parseCellValueByCellIndexAndSheetIndexWithLimitValues(Integer cellIndex, Integer sheetIndex,                                                                                     Integer limit, byte[] fileBytes) throws IOException {         Set&lt;String&gt; values = new HashSet&lt;&gt;();          try (Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(fileBytes))) {             Sheet sheet = workbook.getSheetAt(sheetIndex);             for (Row row : sheet) {                 Cell cell = row.getCell(cellIndex);                 if (!ObjectUtils.isEmpty(cell) &amp;&amp; Objects.equals(cell.getCellType(), CellType.STRING)) {                     String value = cell.getStringCellValue();                     if (!ObjectUtils.isEmpty(value)) {                         values.add(value.toLowerCase());                     }                     if (Objects.nonNull(limit) &amp;&amp; values.size() &gt;= limit) {                         break;                     }                 }             }         }         return values;     } }<\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u044e \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u2014 \u0432\u0441\u0451 \u043e\u043a.<\/p>\n<pre><code>2025-04-03T22:03:51.803+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_1@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_5@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_2@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_4@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_3@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : \u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432) \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e<\/code><\/pre>\n<p> \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u044e \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code>2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_1@gmail.com 2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_5@gmail.com 2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_2@gmail.com 2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_4@gmail.com 2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_3@gmail.com 2025-04-04T20:43:33.525+03:00 ERROR 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432)  java.util.concurrent.CompletionException: java.lang.RuntimeException: java.nio.file.NoSuchFileException: C:\\Users\\Knd-a-aaosetskiy\\AppData\\Local\\Temp\\tomcat.8080.4482325861160796176\\work\\Tomcat\\localhost\\ROOT\\upload_8740c826_186b_49e1_b8e7_a358cde48630_00000001.tmp     at java.base\/java.util.concurrent.CompletableFuture.wrapInCompletionException(CompletableFuture.java:323) ~[na:na]     at java.base\/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:359) ~[na:na]     at java.base\/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:364) ~[na:na]     at java.base\/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1851) ~[na:na]     at java.base\/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]     at java.base\/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]     at java.base\/java.lang.Thread.run(Thread.java:1575) ~[na:na] Caused by: java.lang.RuntimeException: java.nio.file.NoSuchFileException: C:\\Users\\Knd-a-aaosetskiy\\AppData\\Local\\Temp\\tomcat.8080.4482325861160796176\\work\\Tomcat\\localhost\\ROOT\\upload_8740c826_186b_49e1_b8e7_a358cde48630_00000001.tmp     at com.example.file_multithreading_problem.services.FileService.lambda$parseValuesFromFileToDTO$0(FileService.java:43) ~[classes\/:na]     at java.base\/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1848) ~[na:na]     ... 3 common frames omitted Caused by: java.nio.file.NoSuchFileException: C:\\Users\\Knd-a-aaosetskiy\\AppData\\Local\\Temp\\tomcat.8080.4482325861160796176\\work\\Tomcat\\localhost\\ROOT\\upload_8740c826_186b_49e1_b8e7_a358cde48630_00000001.tmp     at java.base\/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85) ~[na:na]     at java.base\/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) ~[na:na]     at java.base\/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108) ~[na:na]     at java.base\/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:234) ~[na:na]     at java.base\/java.nio.file.Files.newByteChannel(Files.java:380) ~[na:na]     at java.base\/java.nio.file.Files.newByteChannel(Files.java:432) ~[na:na]     at java.base\/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420) ~[na:na]     at java.base\/java.nio.file.Files.newInputStream(Files.java:160) ~[na:na]     at org.apache.tomcat.util.http.fileupload.disk.DiskFileItem.getInputStream(DiskFileItem.java:196) ~[tomcat-embed-core-10.1.34.jar:10.1.34]     at org.apache.catalina.core.ApplicationPart.getInputStream(ApplicationPart.java:97) ~[tomcat-embed-core-10.1.34.jar:10.1.34]     at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile.getBytes(StandardMultipartHttpServletRequest.java:259) ~[spring-web-6.2.2.jar:6.2.2]     at com.example.file_multithreading_problem.services.FileService.lambda$parseValuesFromFileToDTO$0(FileService.java:38) ~[classes\/:na]     ... 4 common frames omitted  2025-04-04T20:43:33.533+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : \u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432) \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e<\/code><\/pre>\n<figure class=\"bordered full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/870\/4b8\/5f7\/8704b85f7ed3960834e2e5fc0822ef44.png\" alt=\"\u041d\u0430\u0447\u0430\u043b\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" title=\"\u041d\u0430\u0447\u0430\u043b\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" width=\"800\" height=\"556\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/870\/4b8\/5f7\/8704b85f7ed3960834e2e5fc0822ef44.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/870\/4b8\/5f7\/8704b85f7ed3960834e2e5fc0822ef44.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041d\u0430\u0447\u0430\u043b\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0430 \u0442\u043e\u0447\u043d\u043e \u043b\u0438 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0438\u0448\u043b\u0438 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441?<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8c9\/fe2\/ffb\/8c9fe2ffb7c1e5af3cabd58300eba3dc.png\" alt=\"\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430\" title=\"\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430\" width=\"1664\" height=\"821\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/8c9\/fe2\/ffb\/8c9fe2ffb7c1e5af3cabd58300eba3dc.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8c9\/fe2\/ffb\/8c9fe2ffb7c1e5af3cabd58300eba3dc.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0437 \u0441\u043a\u0440\u0438\u043d\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u0438\u0448\u043b\u0438. \u0422\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0444\u0430\u0439\u043b \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043d\u0430 <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/web\/multipart\/MultipartFile.html\" rel=\"noopener noreferrer nofollow\">MultipartFile<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f Mutipart \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<blockquote>\n<p><em>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439.<\/em><\/p>\n<\/blockquote>\n<blockquote>\n<p><em>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043b\u0438\u0431\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435\u0441\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0435\u0430\u043d\u0441\u0430 \u0438\u043b\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0438\u0449\u0435\u043d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/em><\/p>\n<\/blockquote>\n<p>\u0418\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e <code>MutipartFile<\/code> \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 Spring, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443. \u0410 \u043e\u0442\u043a\u0443\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 http \u0437\u0430\u043f\u0440\u043e\u0441\u0430?<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0438\u0437 <code>DispatcherServlet<\/code>.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0433\u0434\u0435 \u0444\u0430\u0439\u043b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>1. <code>DispatcherServlet.doDispatch()<\/code><br \/>2. <code>StandardServletMultipartResolver.resolveMultipart()<\/code><br \/>3. <code>HttpServletRequest.getParts()<\/code> (Servlet API)<br \/>4. <code>org.apache.catalina.connector.Request.parseParts()<\/code> (Tomcat)<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ef\/504\/abb\/1ef504abbce3d310bf80b09aa39a5814.png\" alt=\"\u0412\u044b\u0434\u0435\u043b\u0438\u043b \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\" title=\"\u0412\u044b\u0434\u0435\u043b\u0438\u043b \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\" width=\"1728\" height=\"884\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1ef\/504\/abb\/1ef504abbce3d310bf80b09aa39a5814.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ef\/504\/abb\/1ef504abbce3d310bf80b09aa39a5814.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u044b\u0434\u0435\u043b\u0438\u043b \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043a, \u043c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0422\u043e\u043c\u043a\u0430\u0442\u043e\u043c \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043d\u043e \u043a\u0442\u043e \u0438 \u043a\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u044f\u0435\u0442?<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0441\u0442\u0440\u043e\u0447\u043a\u0430\u0445 <code>DispatcherServlet.doDispatch()<\/code>.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ce3\/a08\/725\/ce3a08725bcdaa10d848587602cb49cf.png\" alt=\"\u0412 \u0431\u043b\u043e\u043a\u0435 finally \u0438\u0434\u0451\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\" title=\"\u0412 \u0431\u043b\u043e\u043a\u0435 finally \u0438\u0434\u0451\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443\" width=\"1270\" height=\"592\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/ce3\/a08\/725\/ce3a08725bcdaa10d848587602cb49cf.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ce3\/a08\/725\/ce3a08725bcdaa10d848587602cb49cf.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412 \u0431\u043b\u043e\u043a\u0435 finally \u0438\u0434\u0451\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443<\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0437 \u043a\u043e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u0442\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0435 \u043d\u0430\u0447\u0430\u0442\u0430, \u0442\u043e \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/208\/9c3\/e01\/2089c3e019ade2a818b995b82cb37297.png\" width=\"1129\" height=\"343\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/208\/9c3\/e01\/2089c3e019ade2a818b995b82cb37297.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/208\/9c3\/e01\/2089c3e019ade2a818b995b82cb37297.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u043e\u0434 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439.<br \/>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 Spring \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u044f\u0435\u0442 <code>MultipartFile<\/code>. <\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/667\/229\/120\/667229120e2f5a67b5284cbe21fa6bed.jpeg\" alt=\"\u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0451\u043b \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" title=\"\u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0451\u043b \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\" width=\"400\" height=\"318\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/667\/229\/120\/667229120e2f5a67b5284cbe21fa6bed.jpeg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/667\/229\/120\/667229120e2f5a67b5284cbe21fa6bed.jpeg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448\u0451\u043b \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/div>\n<\/figure>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u043e\u043c\u0435\u0440 1: \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c Spring, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439<\/strong><\/p>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u0435\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f: \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u044c Spring, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439:<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043d\u043e\u0441\u0438\u043c <code>CompletableFuture<\/code> \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/41b\/be0\/5b8\/41bbe05b87ffa74b688bbe0dd4a19739.png\" alt=\"\u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u044b\u043d\u0435\u0441\u0442\u0438 CompletableFuture \u0432 Controller, \u0447\u0442\u043e\u0431\u044b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f Async \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430\" title=\"\u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u044b\u043d\u0435\u0441\u0442\u0438 CompletableFuture \u0432 Controller, \u0447\u0442\u043e\u0431\u044b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f Async \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430\" width=\"1232\" height=\"561\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/41b\/be0\/5b8\/41bbe05b87ffa74b688bbe0dd4a19739.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/41b\/be0\/5b8\/41bbe05b87ffa74b688bbe0dd4a19739.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u044b\u043d\u0435\u0441\u0442\u0438 CompletableFuture \u0432 Controller, \u0447\u0442\u043e\u0431\u044b \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f Async \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0442\u0430\u0432\u0438\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>Async<\/code> \u043d\u0430\u0434 \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e\u0431\u044b Spring \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439.<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/93e\/c13\/962\/93ec1396203a974c52b1ecf9b8a52b34.png\" alt=\"\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u00a0@Async, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 Spring \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432.  \" title=\"\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u00a0@Async, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 Spring \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432.  \" width=\"1287\" height=\"817\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/93e\/c13\/962\/93ec1396203a974c52b1ecf9b8a52b34.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/93e\/c13\/962\/93ec1396203a974c52b1ecf9b8a52b34.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u00a0<code>@Async<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 Spring \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432.  <\/figcaption><\/div>\n<\/figure>\n<p>\u0418 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044e <code>@EnableAsync<\/code>\u043a \u043a\u043b\u0430\u0441\u0441\u0443 \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <code>@SpringBootApplication<\/code>.<br \/>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0443\u0448\u043b\u0430.\u00a0<\/p>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u043e\u043c\u0435\u0440 2: \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442 \u0434\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432 CompletableFuture<\/strong><\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0b5\/61b\/01c\/0b561b01cb5109a74245d0286f671f74.png\" width=\"1303\" height=\"1013\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/0b5\/61b\/01c\/0b561b01cb5109a74245d0286f671f74.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0b5\/61b\/01c\/0b561b01cb5109a74245d0286f671f74.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d? <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u0441\u0435\u0440\u0432\u0438\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 <code>json<\/code> \u0432 <code>form-data<\/code>, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0435\u0449\u0451 \u0447\u0430\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 excel \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u0435\u0440\u0451\u0442, \u0438 \u0432\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0432\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 <code>OutOfMemoryError<\/code>.  <\/p>\n<p>\u0418\u0442\u043e\u0433:<\/p>\n<ul>\n<li>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0444\u0430\u0439\u043b\u0430 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/web\/multipart\/MultipartFile.html\" rel=\"noopener noreferrer nofollow\">MultipartFile<\/a>, \u0442\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0439\u0442\u0435 \u0447\u0442\u043e \u0441\u0440\u043e\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0435 <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/web\/multipart\/MultipartFile.html\" rel=\"noopener noreferrer nofollow\">MultipartFile<\/a> \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435, \u0442\u043e \u043b\u0438\u0431\u043e \u0441\u043e\u043e\u0431\u0449\u0438\u0442\u0435 Spring \u043e\u0431 \u044d\u0442\u043e\u043c \u0438\u043b\u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0444\u0430\u0439\u043b \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0438: <\/strong><a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/web\/multipart\/MultipartFile.html%EF%BF%BC%EF%BF%BChttps:\/\/github.com\/AlexeyOs\/FileMultithreadingProblem%EF%BF%BC%EF%BF%BChttps:\/\/ru.stackoverflow.com\/questions\/1609849\/%D0%9F%D1%80%D0%BE%D0%B1%D0%BB%D0%B5%D0%BC%D0%B0-%D1%81-%D0%BE%D0%B1%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%BE%D0%B9-%D1%84%D0%B0%D0%B9%D0%BB%D0%B0-%D0%B2-%D0%BC%D0%BD%D0%BE%D0%B3%D0%BE%D0%BF%D0%BE%D1%82%D0%BE%D1%87%D0%BD%D0%BE%D0%BC-%D1%80%D0%B5%D0%B6%D0%B8%D0%BC%D0%B5\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0434\u043b\u044f MultiPart<\/a>, <a href=\"https:\/\/github.com\/AlexeyOs\/FileMultithreadingProblem\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0434<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/928016\/\"> https:\/\/habr.com\/ru\/articles\/928016\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0435\u0439, \u0438 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e Java\u2011\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0441 2018 \u0433\u043e\u0434\u0430. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 <code>MultipartFile<\/code> \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435. \u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0438 \u043a\u0430\u043a\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442.<\/p>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u044f\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u043d\u043e\u0432\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 Excel-\u0444\u0430\u0439\u043b\u043e\u0432: \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0443 HTTP-200 (\u0431\u0435\u0437 \u0434\u0430\u043d\u043d\u044b\u0445), \u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435.<\/p>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0430 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f. \u0414\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<pre><code>@RestController @RequestMapping public class FileController {      private final FileService fileService;      @Autowired     public FileController(FileService fileService) {         this.fileService = fileService;     }      @PostMapping(value = \"\/upload-from-files\", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)     public ResponseEntity&lt;Void&gt; saveFromFiles(@RequestPart(value = \"files\", required = false) List&lt;MultipartFile&gt; files) {         fileService.parseValuesFromFileToDTO(files);         return new ResponseEntity&lt;&gt;(HttpStatus.OK);     } }<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>CompletableFuture<\/code>, \u0447\u0442\u043e\u0431\u044b \u0440\u0443\u043a\u0430\u043c\u0438 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0438.<\/p>\n<pre><code>@Service public class FileService {     static final Logger log = LoggerFactory.getLogger(FileService.class);     public void parseValuesFromFileToDTO(List&lt;MultipartFile&gt; files) {         CompletableFuture&lt;Void&gt; filesDtoFromFile = CompletableFuture.runAsync(() -&gt;         {             for(MultipartFile file : files) {                 final Integer cellIndex = 0;                 final Integer sheetIndex = 0;                 final Integer limitValues = 100;                 try {                     Set&lt;String&gt; emailsFromFile = parseCellValueByCellIndexAndSheetIndexWithLimitValues(cellIndex,                             sheetIndex,                             limitValues,                             file.getBytes());                     for (String email:emailsFromFile) {                         log.info(email);                     }                 } catch (IOException e) {                     throw new RuntimeException(e);                 }             }          }, Executors.newSingleThreadExecutor()).exceptionally((e) -&gt; {             log.error(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432)\", e);             return null;         });         filesDtoFromFile.thenRun(() -&gt; log.info(\"\u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432) \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e\"));     }      \/***      * \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u0430 \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439      *      * @param cellIndex  - \u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0444\u0430\u0439\u043b\u0430.      * @param sheetIndex - \u0438\u043d\u0434\u0435\u043a\u0441 \u043b\u0438\u0441\u0442\u0430 \u0444\u0430\u0439\u043b\u0430.      * @param limit      - \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.      *      * @return \u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430.      *\/     public static Set&lt;String&gt; parseCellValueByCellIndexAndSheetIndexWithLimitValues(Integer cellIndex, Integer sheetIndex,                                                                                     Integer limit, byte[] fileBytes) throws IOException {         Set&lt;String&gt; values = new HashSet&lt;&gt;();          try (Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(fileBytes))) {             Sheet sheet = workbook.getSheetAt(sheetIndex);             for (Row row : sheet) {                 Cell cell = row.getCell(cellIndex);                 if (!ObjectUtils.isEmpty(cell) &amp;&amp; Objects.equals(cell.getCellType(), CellType.STRING)) {                     String value = cell.getStringCellValue();                     if (!ObjectUtils.isEmpty(value)) {                         values.add(value.toLowerCase());                     }                     if (Objects.nonNull(limit) &amp;&amp; values.size() &gt;= limit) {                         break;                     }                 }             }         }         return values;     } }<\/code><\/pre>\n<p>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u044e \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u2014 \u0432\u0441\u0451 \u043e\u043a.<\/p>\n<pre><code>2025-04-03T22:03:51.803+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_1@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_5@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_2@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_4@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_3@gmail.com 2025-04-03T22:03:51.804+03:00  INFO 15940 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : \u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432) \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e<\/code><\/pre>\n<p> \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u044e \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code>2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_1@gmail.com 2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_5@gmail.com 2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_2@gmail.com 2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_4@gmail.com 2025-04-04T20:43:33.524+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : test1_3@gmail.com 2025-04-04T20:43:33.525+03:00 ERROR 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : \u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432)  java.util.concurrent.CompletionException: java.lang.RuntimeException: java.nio.file.NoSuchFileException: C:\\Users\\Knd-a-aaosetskiy\\AppData\\Local\\Temp\\tomcat.8080.4482325861160796176\\work\\Tomcat\\localhost\\ROOT\\upload_8740c826_186b_49e1_b8e7_a358cde48630_00000001.tmp     at java.base\/java.util.concurrent.CompletableFuture.wrapInCompletionException(CompletableFuture.java:323) ~[na:na]     at java.base\/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:359) ~[na:na]     at java.base\/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:364) ~[na:na]     at java.base\/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1851) ~[na:na]     at java.base\/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[na:na]     at java.base\/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[na:na]     at java.base\/java.lang.Thread.run(Thread.java:1575) ~[na:na] Caused by: java.lang.RuntimeException: java.nio.file.NoSuchFileException: C:\\Users\\Knd-a-aaosetskiy\\AppData\\Local\\Temp\\tomcat.8080.4482325861160796176\\work\\Tomcat\\localhost\\ROOT\\upload_8740c826_186b_49e1_b8e7_a358cde48630_00000001.tmp     at com.example.file_multithreading_problem.services.FileService.lambda$parseValuesFromFileToDTO$0(FileService.java:43) ~[classes\/:na]     at java.base\/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1848) ~[na:na]     ... 3 common frames omitted Caused by: java.nio.file.NoSuchFileException: C:\\Users\\Knd-a-aaosetskiy\\AppData\\Local\\Temp\\tomcat.8080.4482325861160796176\\work\\Tomcat\\localhost\\ROOT\\upload_8740c826_186b_49e1_b8e7_a358cde48630_00000001.tmp     at java.base\/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85) ~[na:na]     at java.base\/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) ~[na:na]     at java.base\/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108) ~[na:na]     at java.base\/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:234) ~[na:na]     at java.base\/java.nio.file.Files.newByteChannel(Files.java:380) ~[na:na]     at java.base\/java.nio.file.Files.newByteChannel(Files.java:432) ~[na:na]     at java.base\/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420) ~[na:na]     at java.base\/java.nio.file.Files.newInputStream(Files.java:160) ~[na:na]     at org.apache.tomcat.util.http.fileupload.disk.DiskFileItem.getInputStream(DiskFileItem.java:196) ~[tomcat-embed-core-10.1.34.jar:10.1.34]     at org.apache.catalina.core.ApplicationPart.getInputStream(ApplicationPart.java:97) ~[tomcat-embed-core-10.1.34.jar:10.1.34]     at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile.getBytes(StandardMultipartHttpServletRequest.java:259) ~[spring-web-6.2.2.jar:6.2.2]     at com.example.file_multithreading_problem.services.FileService.lambda$parseValuesFromFileToDTO$0(FileService.java:38) ~[classes\/:na]     ... 4 common frames omitted  2025-04-04T20:43:33.533+03:00  INFO 9020 --- [File Multithreading Problem] [pool-2-thread-1] c.e.f.services.FileService               : \u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430(\u043e\u0432) \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e<\/code><\/pre>\n<figure class=\"bordered full-width\">\n<div><figcaption>\u041d\u0430\u0447\u0430\u043b\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0430 \u0442\u043e\u0447\u043d\u043e \u043b\u0438 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0438\u0448\u043b\u0438 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441?<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0437 \u0441\u043a\u0440\u0438\u043d\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u043e\u0447\u043d\u043e \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u0438\u0448\u043b\u0438. \u0422\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0444\u0430\u0439\u043b \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043d\u0430 <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/web\/multipart\/MultipartFile.html\" rel=\"noopener noreferrer nofollow\">MultipartFile<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f Mutipart \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<blockquote>\n<p><em>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439.<\/em><\/p>\n<\/blockquote>\n<blockquote>\n<p><em>\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043b\u0438\u0431\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435\u0441\u0435\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0435\u0430\u043d\u0441\u0430 \u0438\u043b\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e. \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0438\u0449\u0435\u043d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/em><\/p>\n<\/blockquote>\n<p>\u0418\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e <code>MutipartFile<\/code> \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442 Spring, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443. \u0410 \u043e\u0442\u043a\u0443\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 http \u0437\u0430\u043f\u0440\u043e\u0441\u0430?<\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0438\u0437 <code>Di<\/code><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-467950","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/467950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=467950"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/467950\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=467950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=467950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=467950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}