Problem observed with 1.5.1, 1.7.0, and nightly build 1.8.0-dev-20020813. POIFS does not "write" an empty document stream correctly (i.e. a document that is zero bytes in length). Failure is observed when trying to read the document in the form of an IOException with the message of either "Cannot remove block[ 0 ]; out of range" or "block[ 0 ] already removed". Example method to reproduce: // construct a new POIFSFileSystem with an empty document POIFSFileSystem fs = new POIFSFileSystem(); fs.getRoot().createDocument("Foo", new ByteArrayInputStream(new byte[0])); // save the document into a byte array ByteArrayOutputStream out = new ByteArrayOutputStream(); fs.writeFilesystem(out); // now try to read the POIFSFileSystem from that byte array. new POIFSFileSystem(new ByteArrayInputStream(out.toByteArray())); This was recently posted on poi-dev, but has been added here to make sure the bug is tracked and not forgotten about. The post on poi-dev has much more detail than what's here. See: http://www.mail-archive.com/poi-dev%40jakarta.apache.org/msg03105.html
Created attachment 11642 [details] Outlook (CDF?) expects -2 (end of chain) for empty SBAT propertys' start_block
Created attachment 20715 [details] Unit test I can confirm that Anand's patch fixes the issue, and here is a unit test I wrote while confirming it.
Patch and test applied, thanks