Bug 62165 - OldExcelExtractor closed NPOIFSFileSystem too early
Summary: OldExcelExtractor closed NPOIFSFileSystem too early
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.17-FINAL
Hardware: All All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-08 17:27 UTC by Billow
Modified: 2018-04-04 19:41 UTC (History)
0 users



Attachments
OldExcelExtractor patch file to fix the open stream bug (806 bytes, patch)
2018-03-08 17:27 UTC, Billow
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Billow 2018-03-08 17:27:25 UTC
Created attachment 35756 [details]
OldExcelExtractor patch file to fix the open stream bug

open(InputStream biffStream) closed the NPOIFSFileSystem  right after open which is wrong. We should only close it when open failed.

The buggy code:
            try {
                open(poifs);
            } finally {
                poifs.close();
            }

Should be:
            try {
                open(poifs);
                toClose = poifs; // Fixed by GR, we should not close it here
            } finally {
                if (toClose == null) {
                    poifs.close();
                }
            }

Attached is the patch file
Comment 1 Dominik Stadler 2018-04-04 19:41:32 UTC
This should be applied now via r1828377 and will be included in Apache POI 4.0.0, thanks for the bug-report.