Bug 62165

Summary: OldExcelExtractor closed NPOIFSFileSystem too early
Product: POI Reporter: Billow <billowgao>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: critical    
Priority: P2    
Version: 3.17-FINAL   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: OldExcelExtractor patch file to fix the open stream 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.