Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in COSName.getString #1479

Open
THausherr opened this issue Aug 31, 2024 · 2 comments
Open

NullPointerException in COSName.getString #1479

THausherr opened this issue Aug 31, 2024 · 2 comments
Assignees

Comments

@THausherr
Copy link

I sometimes get this:

org.verapdf.core.ValidationException: Caught unexpected runtime exception during validation
at org.verapdf.pdfa.validation.validators.BaseValidator.validate(BaseValidator.java:110)
at org.apache.pdfbox.examples.pdfa.MergePDFATest.testMergePDFA(MergePDFATest.java:83)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NullPointerException
at org.verapdf.cos.COSName.getString(COSName.java:112)
at org.verapdf.parser.postscript.PSOperator.(PSOperator.java:44)
at org.verapdf.parser.postscript.PSObject.getPSObject(PSObject.java:72)
at org.verapdf.parser.COSParser.nextObject(COSParser.java:110)
at org.verapdf.pd.font.cmap.CMapParser.processObject(CMapParser.java:93)
at org.verapdf.pd.font.cmap.CMapParser.parse(CMapParser.java:80)
at org.verapdf.pd.font.cmap.CMapFactory.getCMap(CMapFactory.java:60)
at org.verapdf.pd.font.cmap.PDCMap.getCMapFile(PDCMap.java:128)
at org.verapdf.pd.font.cmap.PDCMap.getCMapFile(PDCMap.java:111)
at org.verapdf.pd.font.PDType0Font.(PDType0Font.java:63)
at org.verapdf.factory.fonts.PDFontFactory.getPDFont(PDFontFactory.java:65)
at org.verapdf.pd.PDResources.getFont(PDResources.java:146)
at org.verapdf.gf.model.impl.pd.util.PDResourcesHandler.getFont(PDResourcesHandler.java:103)
at org.verapdf.gf.model.impl.pd.util.PDResourcesHandler.getFont(PDResourcesHandler.java:89)
at org.verapdf.gf.model.factory.operators.OperatorParser.parseOperator(OperatorParser.java:366)
at org.verapdf.gf.model.factory.operators.OperatorFactory.operatorsFromTokens(OperatorFactory.java:113)
at org.verapdf.gf.model.impl.pd.GFPDContentStream.parseOperators(GFPDContentStream.java:152)
at org.verapdf.gf.model.impl.pd.GFPDContentStream.isContainsTransparency(GFPDContentStream.java:195)
at org.verapdf.gf.model.impl.pd.GFPDPage.parseContentStream(GFPDPage.java:248)
at org.verapdf.gf.model.impl.pd.GFPDPage.getContentStream(GFPDPage.java:228)
at org.verapdf.gf.model.impl.pd.GFPDPage.getLinkedObjects(GFPDPage.java:132)
at org.verapdf.pdfa.validation.validators.BaseValidator.addAllLinkedObjects(BaseValidator.java:232)
at org.verapdf.pdfa.validation.validators.BaseValidator.checkNext(BaseValidator.java:199)
at org.verapdf.pdfa.validation.validators.BaseValidator.validate(BaseValidator.java:144)
at org.verapdf.pdfa.validation.validators.BaseValidator.validate(BaseValidator.java:108)
... 8 more

The file is ok:
Merged_PDFA.pdf

Version used:

    <dependency>
        <groupId>org.verapdf</groupId>
        <artifactId>validation-model-jakarta</artifactId>
        <version>1.26.1</version>
        <scope>test</scope>
    </dependency>

Code:

VeraGreenfieldFoundryProvider.initialise();
PDFAFlavour flavour = PDFAFlavour.fromString("1b");
try (PDFAParser parser = Foundries.defaultInstance().createParser(new File(pdfaMergedFilename), flavour))
{
    PDFAValidator validator = Foundries.defaultInstance().createValidator(flavour, false);
    ValidationResult veraResult = validator.validate(parser);
    assertTrue(veraResult.isCompliant());
}

I wonder if this could be because verapdf is called twice and in parallel in this build test (the other code is the same)

@MaximPlusov MaximPlusov self-assigned this Aug 31, 2024
@bdoubrov
Copy link
Contributor

@THausherr thanks a lot for reporting this issue.

In general, we aim to guarantee that veraPDF can run validation of several files in parallel, keeping all cached data from PDF parser thread local. We'll do more tests, but so far were able to reproduce this problem if the same PDF file is parsed in parallel. Is this also the case of your tests? Or you get this error even if different files are validated at the same time?

@THausherr
Copy link
Author

No it's not the same file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants