fixed re-open of bug #42844. HSSFEventFactory silently skips unknown records that happen to be continued.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@575406 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b65d864b2c
commit
edf5dc307b
@ -22,15 +22,7 @@ import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.hssf.eventusermodel.HSSFUserException;
|
||||
import org.apache.poi.hssf.record.RecordFormatException;
|
||||
import org.apache.poi.hssf.record.Record;
|
||||
import org.apache.poi.hssf.record.RecordInputStream;
|
||||
import org.apache.poi.hssf.record.RecordFactory;
|
||||
import org.apache.poi.hssf.record.ContinueRecord;
|
||||
import org.apache.poi.hssf.record.DrawingRecord;
|
||||
import org.apache.poi.hssf.record.DrawingGroupRecord;
|
||||
import org.apache.poi.hssf.record.ObjRecord;
|
||||
import org.apache.poi.hssf.record.TextObjectRecord;
|
||||
import org.apache.poi.hssf.record.*;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
/**
|
||||
@ -215,7 +207,11 @@ public class HSSFEventFactory
|
||||
rec = lastRec;
|
||||
}
|
||||
else {
|
||||
throw new RecordFormatException("Records should handle ContinueRecord internally. Should not see this exception");
|
||||
if (rec instanceof UnknownRecord) {
|
||||
;//silently skip records we don't know about
|
||||
} else {
|
||||
throw new RecordFormatException("Records should handle ContinueRecord internally. Should not see this exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
src/testcases/org/apache/poi/hssf/data/42844.xls
Normal file
BIN
src/testcases/org/apache/poi/hssf/data/42844.xls
Normal file
Binary file not shown.
@ -76,6 +76,24 @@ public class TestHSSFEventFactory extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unknown records can be continued.
|
||||
* Check that HSSFEventFactory doesn't break on them.
|
||||
* (the test file was provided in a reopen of bug #42844)
|
||||
*/
|
||||
public void testUnknownContinueRecords() throws Exception {
|
||||
File f = new File(dirname + "/42844.xls");
|
||||
|
||||
HSSFRequest req = new HSSFRequest();
|
||||
MockHSSFListener mockListen = new MockHSSFListener();
|
||||
req.addListenerForAllRecords(mockListen);
|
||||
|
||||
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(f));
|
||||
HSSFEventFactory factory = new HSSFEventFactory();
|
||||
factory.processWorkbookEvents(req, fs);
|
||||
|
||||
assertTrue("no errors while processing the file", true);
|
||||
}
|
||||
|
||||
private static class MockHSSFListener implements HSSFListener {
|
||||
private MockHSSFListener() {}
|
||||
|
Loading…
Reference in New Issue
Block a user