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

Fix NullPointer exception in PDFALTOOutlineSaxHandler #729

Merged
merged 6 commits into from Apr 14, 2021

Conversation

lfoppiano
Copy link
Collaborator

@lfoppiano lfoppiano commented Mar 9, 2021

... update of #715

CC @lucbouge

lucbouge and others added 3 commits February 16, 2021 15:32
I observed the following error. 

févr. 12, 2021 3:20:44 PM org.grobid.core.document.Document addTokenizedDocument
GRAVE: Cannot parse file: my_dir/grobid-0.6.1/grobid-home/tmp/ZW3PpM4E9g.lxml_outline.xml

févr. 12, 2021 3:20:44 PM org.grobid.core.document.Document addTokenizedDocument
GRAVE: Cannot parse file: my_dir/grobid-0.6.1/grobid-home/tmp/ZW3PpM4E9g.lxml_outline.xml

févr. 12, 2021 3:20:46 PM org.grobid.core.engines.ProcessEngine createTraining
INFOS: 2 files processed.

it originates in an illegal nullPointer access in file PDFALTOOutlineSaxHandler.java. 

In understand that the error is not  that "GRAVE". According to @kermitt2, it is simply one of the generated XML file resulting from the PDF parsing which is not XML valid (very frequent) - it has no impact because the outline file (containing the table of content outline if available embedded in the PDF) is not exploited by GROBID for the moment - it's to allow some possible improvements in the future. The error is more a reminder for the developers... the XML parser that classifies it as "GRAVE" but it would be rather INFO for us.

Unfortunately, a side effect might have been overlooked. If father is null, then father.addChild(currentNode) is called with a nullPointer exception.

This exception is caught by catch (Exception e) at line 372 in grobid-core/src/main/java/org/grobid/core/document/Document.java where the error message "Cannot parse" is misleading.

I think an additional else is just missing.
I cleaned up the correction as requested. Luc.
…ing a test case, rename test to match the class name
@lfoppiano lfoppiano added the bug From Hemiptera and especially its suborder Heteroptera label Mar 9, 2021
@lfoppiano lfoppiano requested a review from kermitt2 March 9, 2021 22:27
@coveralls
Copy link

coveralls commented Mar 9, 2021

Coverage Status

Coverage increased (+0.8%) to 38.959% when pulling 01e0e4f on lucbouge-patch-1 into bb8bd0e on master.

@lfoppiano lfoppiano added this to the 0.6.2 milestone Mar 15, 2021
@kermitt2 kermitt2 modified the milestones: 0.6.2, 0.7.0 Mar 20, 2021
@kermitt2
Copy link
Owner

Ready to merge, no?

@lfoppiano
Copy link
Collaborator Author

Yes 👍

@kermitt2 kermitt2 merged commit deaed0c into master Apr 14, 2021
@lfoppiano lfoppiano deleted the lucbouge-patch-1 branch April 15, 2021 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug From Hemiptera and especially its suborder Heteroptera
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants