[
https://issues.apache.org/jira/browse/PDFBOX-1586?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
James Green updated PDFBOX-1586:
--------------------------------
Attachment: TestBuildNewDocumentFromMultipleSources.java
Unit test that demonstrates the problem and causes our stack trace.
-------------------------------------------------------------------------------
Test set: org.apache.pdfbox.TestBuildNewDocumentFromMultipleSources
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.626 sec <<<
FAILURE!
testCreateDocument(org.apache.pdfbox.TestBuildNewDocumentFromMultipleSources)
Time elapsed: 0.574 sec <<< ERROR!
org.apache.pdfbox.exceptions.COSVisitorException:
java.lang.IndexOutOfBoundsException: Index: 13, Size: 0
at
org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1354)
at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:217)
at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:206)
at
org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:525)
at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:435)
at
org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1122)
at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:552)
at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1501)
at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1335)
at
org.apache.pdfbox.TestBuildNewDocumentFromMultipleSources.testCreateDocument(TestBuildNewDocumentFromMultipleSources.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
Caused by: java.lang.IndexOutOfBoundsException: Index: 13, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at
org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:84)
at
org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at
org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1337)
... 34 more
> IndexOutOfBoundsException when saving a document (at random)
> ------------------------------------------------------------
>
> Key: PDFBOX-1586
> URL: https://issues.apache.org/jira/browse/PDFBOX-1586
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 1.8.1
> Reporter: James Green
> Assignee: Andreas Lehmkühler
> Priority: Critical
> Fix For: 1.8.2
>
> Attachments: TestBuildNewDocumentFromMultipleSources.java
>
>
> Getting the following stacktrace:
> org.apache.pdfbox.exceptions.COSVisitorException:
> java.lang.IndexOutOfBoundsException: Index: 28, Size: 0
> at
> org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1245)
> at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:201)
> at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:206)
> at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:524)
> at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:434)
> at
> org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1056)
> at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:496)
> at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1392)
> at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1157)
> at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1138)
> ...
> Caused by: java.lang.IndexOutOfBoundsException: Index: 28, Size: 0
> at java.util.ArrayList.rangeCheck(ArrayList.java:604)
> at java.util.ArrayList.get(ArrayList.java:382)
> at
> org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:84)
> at
> org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96)
> at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
> at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
> at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
> at
> org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1232)
> I'll add some context. We have a "data pipeline" in which a Windows Print
> Monitor sends postscript into a servlet which then uses GhostScript 9.05 to
> convert in-memory to PDF. This PDF is then loaded into PDFBox using
> PDDocument.load().
> At this point we split the original PDF into multiple smaller ones each of
> which is saved to a ByteArrayOutputStream. At the point of save() we are
> having serious reliability issues.
> Taking an original PDF from Ghostscript we have saved this into a unit test
> to replicate the problem without success. If we attempt to re-execute the
> pipeline to take the original PDF and split it, we get apparently random
> percentages of saved documents.
> For instance, on a 990 page document (text, no images), to be split into 990
> 1-page documents using Tomcat 7 with -Xmx=512m:
> Pass 1: 50% were saved, 50% ended with stack traces
> Pass 2: 100% were saved
> Pass 3: 100% were saved
> The same test with -Xmx=128m ended several times with just 1 document saved,
> the rest were stack traces.
> We have also seen this randomly hit a sample document consisting of four
> pages to be split into two two-page documents so it does not appear to be
> memory related. We also added code to catch the IndexOutOfBoundsException and
> make up to ten attempts to repeat, but it seems the save() either works the
> first time or not at all.
> We're thinking there are environmental factors here but we're now focused on
> getting this nailed. Any advice or assistance will be welcomed.
--
This message was sent by Atlassian JIRA
(v6.1#6144)