Bug 48571 - OPCPackage blocks file
Summary: OPCPackage blocks file
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.7-dev
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-01-19 06:43 UTC by Stefan Stern
Modified: 2010-01-24 05:27 UTC (History)
0 users

Adds some lines in order to close all Streams created in OPCPackage (917 bytes, application/octet-stream)
2010-01-19 06:43 UTC, Stefan Stern

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Stern 2010-01-19 06:43:54 UTC
Created attachment 24859 [details]
Adds some lines in order to close all Streams created in OPCPackage

Whenever a file (docx, xlsx, pptx) is opened as OPCPackage, modified and afterwards closed with OPCPackage#close, the Java process keeps a file handle open. In order to modify a document with Word, Excel or Powerpoint, the Java process must terminate in order to release the file.

This happens because OPCPackage creates and opens Streams, which are never closed.

See enclosed Patch for a fix. I couldn't find a problem with that solution so far.

Generally speaking, I have the opinion that everyone creating a stream is responsible for the stream lifecycle and must take care that the stream is closed, after all actions requiring it, are done.
Comment 1 Yegor Kozlov 2010-01-24 05:27:19 UTC
Thanks for the patch, applied in r902565