liuyueyi/quick-media

ImageLoadUtil#getImageByPath 内部 InputStream 没有关闭

Closed this issue · 3 comments

ImageLoadUtil#getImageByPath方法内部使用的 InputStream 没有手动进行关闭,造成服务器的文件句柄一直处于打开状态,最终导致 Too many open files 异常。

ImageIO的read(InputStream input) 方法,内部会根据原始的文件流构构建一个FileCacheImageInputStream对象。此对象的close方法并没有对原始的文件流进行关闭,源码如下
public void close() throws IOException { super.close(); disposerRecord.dispose(); // this will close/delete the cache file stream = null; cache = null; cacheFile = null; StreamCloser.removeFromQueue(closeAction); }
第三行代码中只是将自身对原始文件流的引用置空。而并没有调用其close方法。所以需要在方法外层进行手动关闭

已合并merge,明天升级打包

已打包,版本升级2.6.1

感谢!