This IndexOutOfBoundsException: =============================================================== java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.RangeCheck(ArrayList.java:508) at java.util.ArrayList.get(ArrayList.java:320) at org.apache.fop.layoutmgr.PageBreakingAlgorithm.computeDemerits(PageBreakingAlgorithm.java:644) at org.apache.fop.layoutmgr.BreakingAlgorithm.considerLegalBreak(BreakingAlgorithm.java:737) at org.apache.fop.layoutmgr.PageBreakingAlgorithm.considerLegalBreak(PageBreakingAlgorithm.java:309) at org.apache.fop.layoutmgr.BreakingAlgorithm.findBreakingPoints(BreakingAlgorithm.java:485) at org.apache.fop.layoutmgr.BreakingAlgorithm.findBreakingPoints(BreakingAlgorithm.java:403) at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:338) at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:263) at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:144) at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:233) at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:145) at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:378) at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:194) =============================================================== Workaround: In src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java, replace: =============================================================== if (footnotesPending) { if (footnoteListIndex < footnotesList.size() - 1) { // add demerits for the deferred footnotes demerits += (footnotesList.size() - 1 - footnoteListIndex) * deferredFootnoteDemerits; } if (footnoteElementIndex < ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1) { // add demerits for the footnote split between pages demerits += splitFootnoteDemerits; } } =============================================================== by: =============================================================== if (footnotesPending) { int footnotesListSize = footnotesList.size(); if (footnoteListIndex < footnotesListSize - 1) { // add demerits for the deferred footnotes demerits += (footnotesListSize - 1 - footnoteListIndex) * deferredFootnoteDemerits; } if (footnoteListIndex < footnotesListSize && footnoteElementIndex < ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1) { // add demerits for the footnote split between pages demerits += splitFootnoteDemerits; } } ===============================================================
Hi, Can you please attach to this bug a short FO file showing the exception? It might serve as a testcase. Thanks, Vincent
I'm really sorry but I don't have a short XSL-FO file which may be used to easily reproduce this problem. I just have a large one, moreover full of fo:external-graphic. I presumed that by reading the code pinpointed by the stack trace, you could guess in which conditions such IndexOutOfBoundsException occurs.
I have exact the same problem here, but also only in a very large XSL-FO file. The described workaround does not works correct because the first footnote is always missing.
I did an other workaround, that seems to work: I changed ========================================== private void resetFootnotes(LinkedList elementLists) { for (int i = 0; i < elementLists.size(); i++) { LinkedList removedList = (LinkedList) footnotesList.remove(footnotesList.size() - 1); lengthList.remove(lengthList.size() - 1); // update totalFootnotesLength if (lengthList.size() > 0) { totalFootnotesLength = ((Integer) lengthList.get(lengthList.size() - 1)).intValue(); } else { totalFootnotesLength = 0; } } // update footnotesPending; if (footnotesList.size() == 0) { footnotesPending = false; } } ================================================= to ================================================= private void resetFootnotes(LinkedList elementLists) { for (int i = 0; i < elementLists.size(); i++) { LinkedList removedList = (LinkedList) footnotesList.remove(footnotesList.size() - 1); lengthList.remove(lengthList.size() - 1); // update totalFootnotesLength if (lengthList.size() > 0) { totalFootnotesLength = ((Integer) lengthList.get(lengthList.size() - 1)).intValue(); } else { totalFootnotesLength = 0; } } footnoteListIndex = footnotesList.size() - 1; // update footnotesPending; if (footnotesList.size() == 0) { footnotesPending = false; } } ================================================= (difference is only adding one line) BTW: my FO is very huge too (about 1.7 MB)
Got into same issue, my scenario: * svn-book.fo (Subversion Book), FO file obtained with Xalan-J-2.7.0 (from fop-0.94 distro), not xsltproc. Testcase candidate? (I tried to attach .fo file without results)
resetting P2 open bugs to P3 pending further review