[
https://issues.apache.org/jira/browse/PDFBOX-2225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14066636#comment-14066636
]
Brandon Lyon commented on PDFBOX-2225:
--------------------------------------
I forgot to mention. It only occurs when I try to merge a decent number of
documents (at least 10). Also, another IndexOutOfBoundsException occurs
elsewhere, though it may be unrelated:
Caused by: java.lang.IndexOutOfBoundsException: Index: 145, Size: 145
at java.util.ArrayList.rangeCheck(ArrayList.java:638) [rt.jar:1.8.0_05]
at java.util.ArrayList.get(ArrayList.java:414) [rt.jar:1.8.0_05]
at
org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:110)
[pdfbox-1.8.6.jar:]
at
org.apache.pdfbox.io.RandomAccessFileOutputStream.write(RandomAccessFileOutputStream.java:106)
[pdfbox-1.8.6.jar:]
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
[rt.jar:1.8.0_05]
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
[rt.jar:1.8.0_05]
at java.io.FilterOutputStream.close(FilterOutputStream.java:158)
[rt.jar:1.8.0_05]
at
org.apache.pdfbox.pdfparser.BaseParser.parseCOSStream(BaseParser.java:634)
[pdfbox-1.8.6.jar:]
at
org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:609)
[pdfbox-1.8.6.jar:]
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:194)
[pdfbox-1.8.6.jar:]
> ClassCastException in PDFMergerUtility.appendDocument
> -----------------------------------------------------
>
> Key: PDFBOX-2225
> URL: https://issues.apache.org/jira/browse/PDFBOX-2225
> Project: PDFBox
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 1.8.6
> Environment: Windows 7 64-bit, JDK8, pdfbox 1.8.1 or 1.8.6
> Reporter: Brandon Lyon
> Priority: Minor
>
> Edit: Problem confirmed to exist in 1.8.1 and 1.8.6
> The following exception will occur if any type of Exception other than
> IOException is thrown within a particular try-catch in
> PDFMergerUtility.appendDocument:
> java.lang.ClassCastException: java.lang.IndexOutOfBoundsException cannot be
> cast to java.io.IOException
> For the version I am using (1.8.1), the problem occurs on line 294
> The problem is that the author mistakenly assumed that the only exception
> which could be caught was IOException. I recommend that the cast be removed,
> and that either the additional checked exceptions be thrown by appendDocument
> or wrapped with an unchecked exception
> Also, anyone seeing this may want to investigate why an
> IndexOutOfBoundsException is occurring here, though this is obviously a
> separate issue
--
This message was sent by Atlassian JIRA
(v6.2#6252)