POI 3.0.2 includes handy accessors to DocumentSummary and Summary information streams. Unfortunately old-style setting of POIFS properties doesn't work any more in all cases. By "old-style" I mean direct constructing of DocumentSummaryInformation and SummaryInformation from POIFSFileSystem. "old-style" usage is important, this is how I discovered this bug just before copying POI 3.0.2 to production. Consider two code snippets: (1) set POIFS properties before constructing HSSFWorkbook (works fine) POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("test.xls")); //set POIFS properties after constructing HSSFWorkbook //(a piece of code that used to work up to POI 3.0.2) SummaryInformation summary1 = (SummaryInformation)PropertySetFactory.create(fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME)); summary1.setTitle(title); //write the modified property back to POIFS fs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME).delete(); fs.createDocument(summary1.toInputStream(), SummaryInformation.DEFAULT_STREAM_NAME); HSSFWorkbook wb = new HSSFWorkbook(fs); OutputStream out = new FileOutputStream(""test-saved.xls""); wb.write(out); out.close(); (2) set POIFS properties after constructing HSSFWorkbook (used to work up to POI 3.0.2, fails now) POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("test.xls")); HSSFWorkbook wb = new HSSFWorkbook(fs); //set POIFS properties after constructing HSSFWorkbook //(a piece of code that used to work up to POI 3.0.2) SummaryInformation summary1 = (SummaryInformation)PropertySetFactory.create(fs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME)); summary1.setTitle(title); //write the modified property back to POIFS fs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME).delete(); fs.createDocument(summary1.toInputStream(), SummaryInformation.DEFAULT_STREAM_NAME); OutputStream out = new FileOutputStream(""test-saved.xls""); wb.write(out); out.close(); Unfortunately (2) doesn't work any more with POI 3.0.2. See the unit test in the patch. I think I found a workaround but I don't want to commit it without discussing. The idea is simple: don't read DocumentSummary and Summary in constructor. Instead, read them on first call of POIDocument.getSummaryInformation() or POIDocument.getDocumentSummaryInformation(). Nick, would you please confirm this change is OK to you? Regards, Yegor
Created attachment 21594 [details] The patch
Since this is not an HPSF bug I don't care.
This sounds sane to me. I figured it'd be handy for them to be available to everyone, save each user needing to repeat the code to get at them (I was getting bored of coding it every time at least!) Having them read on demand works for me too though, so I'll apply it in a sec
Patch committed