Correct an eclipse warning around close(), and a related bug that this identified

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1589756 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2014-04-24 14:50:52 +00:00
parent 14a7ae6316
commit 67d97d8894
3 changed files with 11 additions and 1 deletions

View File

@ -403,6 +403,11 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
revert();
return;
}
if (this.contentTypeManager == null) {
logger.log(POILogger.WARN,
"Unable to call close() on a package that hasn't been fully opened yet");
return;
}
// Save the content
ReentrantReadWriteLock l = new ReentrantReadWriteLock();

View File

@ -64,6 +64,10 @@ public final class ZipPackage extends Package {
public ZipPackage() {
super(defaultPackageAccess);
this.zipArchive = null;
try {
this.contentTypeManager = new ZipContentTypeManager(null, this);
} catch (InvalidFormatException e) {}
}
/**

View File

@ -73,7 +73,7 @@ public class XWPFWordExtractor extends POIXMLTextExtractor {
public static void main(String[] args) throws Exception {
if(args.length < 1) {
System.err.println("Use:");
System.err.println(" HXFWordExtractor <filename.docx>");
System.err.println(" XWPFWordExtractor <filename.docx>");
System.exit(1);
}
POIXMLTextExtractor extractor =
@ -81,6 +81,7 @@ public class XWPFWordExtractor extends POIXMLTextExtractor {
args[0]
));
System.out.println(extractor.getText());
extractor.close();
}
public String getText() {