Skip to content

Commit

Permalink
修复文件流需要gc才能关闭的问题 #511
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangjiaju committed Aug 29, 2019
1 parent 7628257 commit e58a683
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/com/alibaba/excel/analysis/ExcelAnalyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,30 @@ public void finish() {
throw new ExcelAnalysisException("Can not close IO", e);
}
try {
if (analysisContext.readWorkbookHolder().getAutoCloseStream()
&& readWorkbookHolder.getInputStream() != null) {
readWorkbookHolder.getInputStream().close();
if (readWorkbookHolder.getOpcPackage() != null) {
readWorkbookHolder.getOpcPackage().close();
}
} catch (Throwable e) {
throw new ExcelAnalysisException("Can not close IO", e);
}
try {
if (readWorkbookHolder.getTempFile() != null) {
FileUtils.delete(readWorkbookHolder.getTempFile());
if (readWorkbookHolder.getPoifsFileSystem() != null) {
readWorkbookHolder.getPoifsFileSystem().close();
}
} catch (Throwable e) {
throw new ExcelAnalysisException("Can not close IO", e);
}
try {
if (readWorkbookHolder.getOpcPackage() != null) {
readWorkbookHolder.getOpcPackage().close();
if (analysisContext.readWorkbookHolder().getAutoCloseStream()
&& readWorkbookHolder.getInputStream() != null) {
readWorkbookHolder.getInputStream().close();
}
} catch (Throwable e) {
throw new ExcelAnalysisException("Can not close IO", e);
}
try {
if (readWorkbookHolder.getPoifsFileSystem() != null) {
readWorkbookHolder.getPoifsFileSystem().close();
if (readWorkbookHolder.getTempFile() != null) {
FileUtils.delete(readWorkbookHolder.getTempFile());
}
} catch (Throwable e) {
throw new ExcelAnalysisException("Can not close IO", e);
Expand Down

0 comments on commit e58a683

Please sign in to comment.