Bug 59287 - Provide a write() method and change semantics of close() to not automatically write
Summary: Provide a write() method and change semantics of close() to not automatically...
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: OPC (show other bugs)
Version: 3.15-dev
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 62985 65215 (view as bug list)
Depends on:
Blocks: 58779 59252 59634 63029
  Show dependency tree
 
Reported: 2016-04-07 18:57 UTC by Dominik Stadler
Modified: 2021-04-27 06:26 UTC (History)
3 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominik Stadler 2016-04-07 18:57:14 UTC
We repeatedly get questions/bug-reports related to the automatic saving of changes on close() for the OPCPackage based formats, it seems to be not expected by most users. 

So we should discuss changing the semantic here to not save on close() by default and ask users to additionally call a new write() method if they need the current behavior. 

It will be a breaking change, but I think the confusion among users is big enough to warrant this change.
Comment 1 Dominik Stadler 2016-04-07 18:58:42 UTC
Bug 59252 is related and is probably solved automatically if this one gets implemented.

Things to take care of here:
* Code-changes
* Tests
* Javadoc in potentially many places
* Documentation on the webpage (with notes about which version changed the behavior)
Comment 2 Nick Burch 2016-04-07 19:03:15 UTC
I think we should probably take a few hours to finish the in-place-write on POIDocument and POIXMLDocument when making this change too - should be easish now that both NPOIFS and OPC support it at the FS level, and would be a good improvement excuse to cover the breaking change!
Comment 3 Andreas Beeker 2018-06-24 21:19:08 UTC
When using write(OutputStream) the currently opened package is also written [1]. How about always working on copy/temporary file and in the case of write()/commit() move it to over the original file?

[1] https://stackoverflow.com/a/50830215/2066598
Comment 4 PJ Fanning 2018-06-25 19:11:05 UTC
Seems like if we want to make this change, this is the right time to do it.
Comment 5 Mark Murphy 2018-06-25 20:06:22 UTC
Seems to me that I had an issue at one point (XML document) where I wanted to read a template, make changes, and save the output as a regular document, but, it would always update the template in place. I don't know if that would have anything to do with this, but we might want to make sure that we can do that as long as we are making changes here.
Comment 6 Andreas Beeker 2018-12-06 07:59:25 UTC
*** Bug 62985 has been marked as a duplicate of this bug. ***
Comment 7 Dominik Stadler 2021-04-27 06:25:35 UTC
*** Bug 65215 has been marked as a duplicate of this bug. ***