最近換個環境執行,結果發現檔案刪除會失敗。我還以為是MultipartFile.transferTo 遇到 FileNotFoundException 問題
,後來發現不是,檔案被 lock 掉。
但沒找到相關錯誤,我都有做close
動作。
我後來發現這個錯誤訊息。1
2
3
4
5WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.itextpdf.text.io.ByteBufferRandomAccessSource$1 (file:/C:/Users/XXX/.m2/repository/com/itextpdf/itextpdf/5.5.13/itextpdf-5.5.13.jar) to method java.nio.DirectByteBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.itextpdf.text.io.ByteBufferRandomAccessSource$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
1 | new PdfReader(new FileInputStream(inFilePath) |
補上FileInputStream就可以跑了。三小
反正採到一個很奇怪的雷。
參考: