Axel Howind created PDFBOX-5758:
-----------------------------------

             Summary: ExceptionInInitializerError when unmapping is not 
supported
                 Key: PDFBOX-5758
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5758
             Project: PDFBox
          Issue Type: Bug
          Components: IO
            Reporter: Axel Howind


When unmapping is not supported, PdfBox throws an ExceptionInInitializerError 
that is not recoverable. The reason is that in IOUtils, the UNMAPPER static 
field is initialized before the Logger is created and when the unmapper can not 
be created, PdfBox tries to write an error message to the log:
 
{code:java}
public final class IOUtils
{
    ...

    static
    {
        UNMAPPER = Optional.ofNullable(AccessController
                .doPrivileged((PrivilegedAction<Consumer<ByteBuffer>>) 
IOUtils::unmapper));
    }

    /**
     * Log instance.
     */
    private static final Logger LOG = LogManager.getLogger(IOUtils.class);

    ...

private static Consumer<ByteBuffer> unmapper()
{
    final Lookup lookup = lookup();
    try
    {
        ...
    }
    catch (SecurityException se)
    {
        LOG.error(
                "Unmapping is not supported because of missing permissions. 
Please grant at least the following permissions: 
RuntimePermission(\"accessClassInPackage.sun.misc\") "
                        + " and ReflectPermission(\"suppressAccessChecks\")",
                se);

    }
    catch (ReflectiveOperationException | RuntimeException e)
    {
        LOG.error("Unmapping is not supported.", e);
    }
    return null;
}{code}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to