[
https://issues.apache.org/jira/browse/PDFBOX-4601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16890011#comment-16890011
]
Timo Boehme edited comment on PDFBOX-4601 at 7/22/19 8:57 AM:
--------------------------------------------------------------
Regarding the exception: the scratch file is enlarged by 16*4kB pages. Thus it
should have the expected size of 196608 (48 4kB pages; it got 3 times enlarged)
and cannot have a size of 192512 (47 4kB pages). Currently when setting the new
file length we rely on RandomAccessFile.setLength(X) to throw an exception if
setting this size is not possible. Somehow setting the new size did not work in
your case and there was no exception.
Does this happen regularly/each time? You may add a check after
{code:java}
raf.setLength(fileLen);
{code}
if the file could not be set to the new length ( {{if (raf.length() != fileLen)
...}} ) and report if that is the case here.
was (Author: tboehme):
Regarding the exception: the scratch file is enlarged by 16*4kB pages. Thus it
should have the expected size of 196608 (48 4kB pages; it got 3 times enlarged)
and cannot have a size of 192512 (47 4kB pages). Currently when setting the new
file length we rely on RandomAccessFile.setLength(X) to throw an exception if
setting this size is not possible. Somehow setting the new size did not work in
your case and there was no exception.
Does this happen regularly/each time? You may add a check after
{code:java}
raf.setLength(fileLen);
{code}
if the file could not be set to the new length ( {{if (raf.length() != fileLen)
...}} ) and report if this here.
> in AWS lambda pdf merge giving error as Error in pdf consolidation: Expected
> scratch file size of 196608 but found 192512
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-4601
> URL: https://issues.apache.org/jira/browse/PDFBOX-4601
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 2.0.12, 2.0.16
> Environment: AWS Lambda
> Reporter: biswajit
> Priority: Major
> Fix For: 2.0.17
>
>
> in AWS lambda pdf merge giving error as
> {{Error in pdf consolidation: Expected scratch file size of 196608 but found
> 192512.}}
> *Code:*
> {code}
> PDFMergerUtility pdfMerger = new PDFMergerUtility();
> pdfMerger.addSources(sources);
> pdfMerger.setDestinationStream(mergedPDFOutputStream);
> pdfMerger.mergeDocuments(MemoryUsageSetting.setupTempFileOnly());
> {code}
> both InputStream and OutputStream are ByteArrayInputStream and
> ByteArrayOutputStream. AWS Lambda environment has 512MB space available only
> for /tmp partition. This could be an issue or not I am not sure. And AWS
> lambda do not permit other directory than /tmp partition to create files.
> And while reading into the code I found below piece of code which I think
> always be true. Because if you add some constant amount to an integer that
> will always be constant amount greater than its original value
> in ScratchFile.java => enlarge() method:
> {code}
> if (pageCount + ENLARGE_PAGE_COUNT > pageCount)
> {
> fileLen += ENLARGE_PAGE_COUNT * PAGE_SIZE;
> raf.setLength(fileLen);
> freePages.set(pageCount, pageCount + ENLARGE_PAGE_COUNT);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]