I tried to upload a file and my service invokes a spring @Async method and passes a file object.
fileAsyncProcessor.process(file);
After this, the file object is becoming null in the process method
public class FileAsyncProcessor {
@Async
public void process(MultipartFile file) {
log.debug("processing file...");
InputStream is = file.getInputStream();
//.....
}
}
file.getInputStream() returs the following error.
ERROR c.d.f.s.util.FileAsyncProcessor - /private/var/tmp/upload_79f329ff_4cd2_46d0_b1a9_d0fac1ae27c2_00000020.tmp (No such file or directory)
java.io.FileNotFoundException: /private/var/tmp/upload_79f329ff_4cd2_46d0_b1a9_d0fac1ae27c2_00000020.tmp (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at org.apache.tomcat.util.http.fileupload.disk.DiskFileItem.getInputStream(DiskFileItem.java:194)
at org.apache.catalina.core.ApplicationPart.getInputStream(ApplicationPart.java:100)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile.getInputStream(StandardMultipartHttpServletRequest.java:250)
at com.de.files.service.util.FileAsyncProcessor.processFile(FileAsyncProcessor.java:58)