mirror of https://github.com/apache/poi.git
Use revert() instead of close() when processing fails
Otherwise we might write partial changes to the underlying file which is unexpected. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1914706 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4b84986671
commit
ffc4795258
|
@ -746,7 +746,7 @@ public class POIXMLDocumentPart {
|
|||
if (coreRel != null) {
|
||||
PackagePart pp = pkg.getPart(coreRel);
|
||||
if (pp == null) {
|
||||
IOUtils.closeQuietly(pkg);
|
||||
pkg.revert();
|
||||
throw new POIXMLException("OOXML file structure broken/invalid - core document '" + coreRel.getTargetURI() + "' not found.");
|
||||
}
|
||||
return pp;
|
||||
|
@ -754,16 +754,16 @@ public class POIXMLDocumentPart {
|
|||
|
||||
coreRel = pkg.getRelationshipsByType(PackageRelationshipTypes.STRICT_CORE_DOCUMENT).getRelationship(0);
|
||||
if (coreRel != null) {
|
||||
IOUtils.closeQuietly(pkg);
|
||||
pkg.revert();
|
||||
throw new POIXMLException("Strict OOXML isn't currently supported, please see bug #57699");
|
||||
}
|
||||
|
||||
IOUtils.closeQuietly(pkg);
|
||||
pkg.revert();
|
||||
throw new POIXMLException("OOXML file structure broken/invalid - no core document found!");
|
||||
} catch (POIXMLException e) {
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
IOUtils.closeQuietly(pkg);
|
||||
pkg.revert();
|
||||
throw new POIXMLException("OOXML file structure broken/invalid", e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue