[
https://issues.apache.org/jira/browse/PDFBOX-4601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16895823#comment-16895823
]
biswajit commented on PDFBOX-4601:
----------------------------------
Hi [~tilman],
Got below response from AWS team. In short they are saying, though it will
start working if they upgrade JDK version, not to use RandomAccessFile APIs as
it make unsafe API call. Could you please use other alternative to assign
length to temp file and provide us new maven repo?
{panel:title=AWS Response}
Our team informs that the issue has its source in an OpenJDK bug (OpenJDK
version 8u201-b09). In summary, the OpenJDK bug will cause setLength method of
RandomAccessFile will stop working correctly, in the Lambda execution
environment. More specifically "setLength" won't change the file size at all.
The dev team can confirm this issue has been fixed in an OpenJDK newer release
and are actively working to integrate the same, although provide no ETA for
that.
Going forward, our team strongly recommends that:
- You avoid using RandomAccessFile feature and avoid using that
Library if possible - this is because it makes unsafe API calls.
- If in production pain, you can use the "AmazonLinux1703" layer
as a stop-gap. Note however that support for this layer by-pass is strictly
supported until Jul 31, 2019, after which it will be irrelevant.
- Regarding the "AmazonLinux1703" layer, we strongly recommend
using the new runtime execution environment, which provided better security
protection & performance; customers using the old execution environment are
exposed to higher security risks.
{panel}
> 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]