You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2011/08/17 13:52:39 UTC

DO NOT REPLY [Bug 51671] New: HWPFDocument.write based on NPOIFSFileSystem throws a NullPointerException

https://issues.apache.org/bugzilla/show_bug.cgi?id=51671

             Bug #: 51671
           Summary: HWPFDocument.write based on NPOIFSFileSystem throws a
                    NullPointerException
           Product: POI
           Version: 3.8-dev
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HWPF
        AssignedTo: dev@poi.apache.org
        ReportedBy: antoni.mylka@aduna-software.com
    Classification: Unclassified


I do this:

InputStream st = ... // stream with the doc file
NPOIFSFileSystem fs = new NPOIFSFileSystem(st);
HWPFDocument doc = new HWPFDocument(fs.getRoot());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
doc.write(baos);

I get this:

java.lang.NullPointerException
    at org.apache.poi.hwpf.HWPFDocument.deleteEntrySafe(HWPFDocument.java:980)
    at org.apache.poi.hwpf.HWPFDocument.write(HWPFDocument.java:951)
...

It seems that the HWPFDocument.write relies on the fact that
directory.getFileSystem() will return a non-null object. Unfortunately, when
using the NPOIFSFileSystem, this is not the case. A workaround would be to add
a 

if (pfs == null) {
    pfs = new POIFSFileSystem();
}

This seems to work for me.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 51671] HWPFDocument.write based on NPOIFSFileSystem throws a NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51671

--- Comment #2 from Antoni Mylka <an...@aduna-software.com> 2011-08-17 12:04:02 UTC ---
Created attachment 27397
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27397
a test doc, to be placed in test-data/document

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 51671] HWPFDocument.write based on NPOIFSFileSystem throws a NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51671

--- Comment #1 from Antoni Mylka <an...@aduna-software.com> 2011-08-17 12:03:27 UTC ---
Created attachment 27396
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27396
A patch which adds the if (pfs==null) check

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 51671] HWPFDocument.write based on NPOIFSFileSystem throws a NullPointerException

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51671

Sergey Vladimirov <vl...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
         OS/Version|                            |All

--- Comment #3 from Sergey Vladimirov <vl...@gmail.com> 2011-08-17 14:54:06 UTC ---
Fixed by using new file system, not existing one.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org