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 SeekableCOSParser.getStream #1464

Open
Lolf1010 opened this issue Jul 15, 2024 · 1 comment
Open

NullPointerException in SeekableCOSParser.getStream #1464

Lolf1010 opened this issue Jul 15, 2024 · 1 comment
Assignees

Comments

@Lolf1010
Copy link

Lolf1010 commented Jul 15, 2024

Hi,
we sometimes get the following exception in our application.
Sadly i can not provide you with a pdf-file to replicate the exception - they are our users pdf-files.

Our code
we are using VeraGreenfieldFoundryProvider
Version 1.26.1

InputStream stream = ...
VeraPDFFoundry foundry = Foundries.defaultInstance()
PDFAParser parser = foundry.createParser(stream)

Stacktrace

java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "org.verapdf.cos.COSObject.isIndirect()" is null
at org.verapdf.parser.SeekableCOSParser.getStream(SeekableCOSParser.java:108)
at org.verapdf.parser.SeekableCOSParser.getDictionary(SeekableCOSParser.java:82)
at org.verapdf.parser.COSParser.nextObject(COSParser.java:157)
at org.verapdf.parser.PDFParser.getObject(PDFParser.java:303)
at org.verapdf.io.Reader.getObject(Reader.java:118)
at org.verapdf.io.Reader.getObject(Reader.java:89)
at org.verapdf.cos.COSDocument.getObject(COSDocument.java:229)
at org.verapdf.cos.COSIndirect.getDirect(COSIndirect.java:430)
at org.verapdf.cos.COSIndirect.getType(COSIndirect.java:79)
at org.verapdf.cos.COSObject.getType(COSObject.java:99)
at org.verapdf.pd.PDCatalog.getMetadata(PDCatalog.java:72)
at org.verapdf.gf.model.GFModelParser.obtainFlavour(GFModelParser.java:165)
at org.verapdf.gf.model.GFModelParser.detectFlavour(GFModelParser.java:102
at org.verapdf.gf.model.GFModelParser.<init>(GFModelParser.java:79) ~[validation-model-jakarta-1.26.1.jar!/:?]
at org.verapdf.gf.model.GFModelParser.createModelWithFlavour(GFModelParser.java:125)
at org.verapdf.gf.model.GFModelParser.createModelWithFlavour(GFModelParser.java:113)
at org.verapdf.gf.model.GFModelParser.createModelWithFlavour(GFModelParser.java:108)
at org.verapdf.gf.foundry.VeraFoundry.createParser(VeraFoundry.java:75)
at org.verapdf.gf.foundry.VeraFoundry.createParser(VeraFoundry.java:65)

Is this a bug?
In the method COSObject.isIndirect there is a return null which causes the exception in the if-statement where the method is called from. I guess a Boolean.TRUE.equals should fix it. Alternatively, if this a bug in the pdf-file, i would have expected that a ModelParsingException is thrown.

Thanks.

@MaximPlusov
Copy link
Contributor

@Lolf1010 thanks for reporting this issue! It's fixed in the latest dev version 1.27.32.

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

2 participants