Bug 50060 - IndexOutOfBoundsException when reading numCharacterRuns() for a read-back DOC file
Summary: IndexOutOfBoundsException when reading numCharacterRuns() for a read-back DOC...
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.7-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Blocks: 50052
  Show dependency tree
Reported: 2010-10-08 10:12 UTC by Viliam Anirud
Modified: 2017-09-11 19:11 UTC (History)
0 users

Testcase for the bug (647 bytes, patch)
2010-10-08 10:13 UTC, Viliam Anirud
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Viliam Anirud 2010-10-08 10:12:07 UTC
When you read, write and read back a document, if fails with the following exception when you try to read numCharacterRuns() for any paragraph:

java.lang.IndexOutOfBoundsException: Index: 8, Size: 8
	at java.util.ArrayList.RangeCheck(ArrayList.java:547)
	at java.util.ArrayList.get(ArrayList.java:322)
	at org.apache.poi.hwpf.usermodel.Range.findRange(Range.java:976)
	at org.apache.poi.hwpf.usermodel.Range.initCharacterRuns(Range.java:925)
	at org.apache.poi.hwpf.usermodel.Range.numCharacterRuns(Range.java:378)
	at org.apache.poi.hwpf.usermodel.TestLists.testWriteRead(TestLists.java:211)

I will attach a diff to TestLists test (included in POI svnrep) that tests this.
Comment 1 Viliam Anirud 2010-10-08 10:13:09 UTC
Created attachment 26140 [details]
Testcase for the bug
Comment 2 Nick Burch 2010-10-22 12:29:12 UTC
I'm sure we have some existing tests that do this, and don't fail for the files in the tests...

In your experimenting, have you found some documents working, or all of them failing? If we can track down a feature of the documents that break (eg have tables, have lists etc), then that'll help us narrow in on the code that's at fault
Comment 3 Nick Burch 2010-10-22 12:42:31 UTC
FWIW, I've added some more testing in r1026399. This shows we do have a serious issue with read + write + read + write not working, but read + write + read does seem ok. I suspect if we fix the former though, it'll help with your case

If you do have some time to look into what we're doing wrong, that'd be great!
Comment 4 Viliam Anirud 2010-10-26 02:47:00 UTC
Currently, we don't need writing at all and I don't have experience here at all. But colleague mentioned, that long time ago we wanted to generate DOC files, but POI generated incorrect files, so he turned to RTF. I created this bug just to show it was not caused by my fix to 50052.
Comment 5 Dominik Stadler 2017-09-11 19:11:26 UTC
Issue is dormant for a very long time and I could not reproduce this problem any more in current versions, therefore I am closing this as WORKSFORME, please reopen or report a new bug if you still have problems like this.