Browse Source

Merge pull request #3102 from gongxuanzhang/fix_auto_close_csv

fix bug:input stream auto close when csv builder set autoClose is false
pull/3104/head
gongxuanzhang 2 years ago committed by GitHub
parent
commit
3712f0221a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      easyexcel-core/src/main/java/com/alibaba/excel/analysis/ExcelAnalyserImpl.java

10
easyexcel-core/src/main/java/com/alibaba/excel/analysis/ExcelAnalyserImpl.java

@ -1,8 +1,5 @@
package com.alibaba.excel.analysis;
import java.io.InputStream;
import java.util.List;
import com.alibaba.excel.analysis.csv.CsvExcelReadExecutor;
import com.alibaba.excel.analysis.v03.XlsSaxAnalyser;
import com.alibaba.excel.analysis.v07.XlsxSaxAnalyser;
@ -26,7 +23,6 @@ import com.alibaba.excel.util.DateUtils;
import com.alibaba.excel.util.FileUtils;
import com.alibaba.excel.util.NumberDataFormatterUtils;
import com.alibaba.excel.util.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
import org.apache.poi.poifs.crypt.Decryptor;
@ -36,6 +32,9 @@ import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.util.List;
/**
* @author jipengfei
*/
@ -177,7 +176,8 @@ public class ExcelAnalyserImpl implements ExcelAnalyser {
// https://github.com/alibaba/easyexcel/issues/2309
try {
if ((readWorkbookHolder instanceof CsvReadWorkbookHolder)
&& ((CsvReadWorkbookHolder)readWorkbookHolder).getCsvParser() != null) {
&& ((CsvReadWorkbookHolder) readWorkbookHolder).getCsvParser() != null
&& analysisContext.readWorkbookHolder().getAutoCloseStream()) {
((CsvReadWorkbookHolder) readWorkbookHolder).getCsvParser().close();
}
} catch (Throwable t) {

Loading…
Cancel
Save