使用poi上傳.xlsx文件時(shí),出現(xiàn)如下錯(cuò)誤
Exception in thread "pool-3-thread-2" java.lang.IllegalStateException: File has been moved - cannot be read again at org.springframework.web.multipart.commons.CommonsMultipartFile.getInputStream(CommonsMultipartFile.java:125) at cn.dataenergy.stat.yxjlbj.web.JlpbbjController$1.run(JlpbbjController.java:200) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)
注意該問(wèn)題是偶爾發(fā)生,并非每次都能重現(xiàn)。而且發(fā)生的概率很低,但是一發(fā)生,可能連續(xù)多次導(dǎo)入都會(huì)爆同樣的錯(cuò)。
第一感這應(yīng)該是一個(gè)多線程問(wèn)題,因?yàn)椴皇敲看文苤噩F(xiàn)很有可能是資源競(jìng)爭(zhēng)。同時(shí)代碼中也確實(shí)用了多線程.在我的controller中:
threadool.execute(new Runnable() { @Override public void run() {