Bug 47563 - Exception when working with table
Summary: Exception when working with table
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.5-dev
Hardware: PC All
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-23 03:53 UTC by udittmer
Modified: 2012-11-05 12:38 UTC (History)
0 users



Attachments
creates DOC files with tables in various sizes; only the 2x2 table is OK (1.89 KB, text/x-java)
2009-07-23 03:53 UTC, udittmer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description udittmer 2009-07-23 03:53:46 UTC
Created attachment 24022 [details]
creates DOC files with tables in various sizes; only the 2x2 table is OK

The attached source file creates DOC files containing a single table. Filling in the table contents only works for the 2x2 table; all other table sizes cause an exception to be thrown like this one:

java.lang.IllegalArgumentException: The end (15) must not be before the start (17)
at org.apache.poi.hwpf.usermodel.Range.sanityCheckStartEnd(Range.java:247)
at org.apache.poi.hwpf.usermodel.Range.<init>(Range.java:181)
at org.apache.poi.hwpf.usermodel.Paragraph.<init>(Paragraph.java:103)
at org.apache.poi.hwpf.usermodel.Range.getParagraph(Range.java:830)
at CreateWordDocTable.test(CreateWordDocTable.java:31)
Comment 1 awm 2009-08-09 14:47:13 UTC
I just tried this and at least with 2007 I can't open the 2x2 either.  It's corrupted.
Comment 2 Yegor Kozlov 2011-06-24 08:22:57 UTC
The problem is still reproducible in trunk.

Yegor
Comment 3 Sergey Vladimirov 2011-07-07 12:57:53 UTC
Fixed in r1143802; shall be part of 3.8-beta4
Comment 4 georgosn 2011-11-15 15:49:06 UTC
Now it fails with

java.lang.ArrayIndexOutOfBoundsException: -1
	at java.util.ArrayList.get(Unknown Source)
	at org.apache.poi.hwpf.usermodel.Range.findRange(Range.java:1060)
	at org.apache.poi.hwpf.usermodel.Range.initCharacterRuns(Range.java:953)
	at org.apache.poi.hwpf.usermodel.Range.initAll(Range.java:931)
	at org.apache.poi.hwpf.usermodel.Range.insertAfter(Range.java:352)
	at org.apache.poi.hwpf.usermodel.Range.insertTableBefore(Range.java:632)
	at lu.intrasoft.poi.utilities.tablehandler.Writer.startTable(Writer.java:52)
	at lu.intrasoft.poi.utilities.tablehandler.WriterTest.testMakeThedocument(WriterTest.java:34)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

any thoughts?
Comment 5 Sergey Vladimirov 2012-11-05 12:38:59 UTC
Can't reproduce with latest trunk code.

Seems to be fixed already, since there is additional checks in Range.findRange(...)