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

NPE in BlockBox.calcMinMaxWidthInlineChildren() (_children is null) #336

Closed
rototor opened this issue Mar 15, 2019 · 4 comments
Closed

NPE in BlockBox.calcMinMaxWidthInlineChildren() (_children is null) #336

rototor opened this issue Mar 15, 2019 · 4 comments

Comments

@rototor
Copy link
Contributor

rototor commented Mar 15, 2019

I get this NPE in production after upgrading to RC18 from RC17. As I am going on holiday next week I don't have time to investigate at the moment whats exactly causing the problem here. When repeating the report generation it then often just works ... I've rolled back to RC17 in the mean time.

This might be some multithread fun/race, but thats just a guess.

 java.lang.NullPointerException
      at com.openhtmltopdf.render.BlockBox.calcMinMaxWidthInlineChildren(BlockBox.java:1726)
      at com.openhtmltopdf.render.BlockBox.calcMinMaxWidth(BlockBox.java:1629)
      at com.openhtmltopdf.render.BlockBox.calcShrinkToFitWidth(BlockBox.java:1506)
      at com.openhtmltopdf.render.BlockBox.calcShrinkToFitWidthIfNeeded(BlockBox.java:981)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:874)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827)
      at com.openhtmltopdf.layout.InlineBoxing.layoutInlineBlockContent(InlineBoxing.java:423)
      at com.openhtmltopdf.layout.InlineBoxing.layoutContent(InlineBoxing.java:314)
      at com.openhtmltopdf.render.BlockBox.layoutInlineChildren(BlockBox.java:1073)
      at com.openhtmltopdf.render.AnonymousBlockBox.layout(AnonymousBlockBox.java:48)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
      at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
      at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
      at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
      at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911)
      at com.openhtmltopdf.newtable.TableRowBox.layoutCell(TableRowBox.java:453)
      at com.openhtmltopdf.newtable.TableRowBox.layoutChildren(TableRowBox.java:206)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911)
      at com.openhtmltopdf.newtable.TableRowBox.layout(TableRowBox.java:89)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
      at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
      at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057)
      at com.openhtmltopdf.newtable.TableSectionBox.layoutChildren(TableSectionBox.java:139)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911)
      at com.openhtmltopdf.newtable.TableSectionBox.layout(TableSectionBox.java:275)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
      at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
      at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057)
      at com.openhtmltopdf.newtable.TableBox.layoutChildren(TableBox.java:311)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827)
      at com.openhtmltopdf.newtable.TableBox.layoutTable(TableBox.java:277)
      at com.openhtmltopdf.newtable.TableBox.layout(TableBox.java:237)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
      at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
      at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
      at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
      at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321)
      at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299)
      at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90)
      at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911)
      at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827)
      at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.layout(PdfBoxRenderer.java:332)
@svenfrauen
Copy link

I also get the same NPE after upgrading to RC18 from RC17. In my case, I could trace this specific issue back to a wrong URL for a remote image in the HTML code, which does not exist and returns a 404 HTTP error page.
I tried the exact HTML input with the RC17 version and I did not throw an exception but just did not display the wrong image.

This HTML code can lead to the exception:

<p><img alt="" src="http://example.com/non-existent-image.jpg" />
</p>

Here is the same exception I get:

java.lang.NullPointerException: null
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidthInlineChildren(BlockBox.java:1726) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidth(BlockBox.java:1629) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidthInlineChildren(BlockBox.java:1744) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidth(BlockBox.java:1629) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidthBlockChildren(BlockBox.java:1698) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidth(BlockBox.java:1626) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.recalcColumn(TableBox.java:1247) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.fullRecalc(TableBox.java:1221) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.calcMinMaxWidth(TableBox.java:1516) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox.calcMinMaxWidth(TableBox.java:158) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidthBlockChildren(BlockBox.java:1698) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidth(BlockBox.java:1626) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.recalcColumn(TableBox.java:1247) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.fullRecalc(TableBox.java:1221) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.calcMinMaxWidth(TableBox.java:1516) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox.calcMinMaxWidth(TableBox.java:158) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidthBlockChildren(BlockBox.java:1698) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.calcMinMaxWidth(BlockBox.java:1626) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.recalcColumn(TableBox.java:1247) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.fullRecalc(TableBox.java:1221) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox$AutoTableLayout.calcMinMaxWidth(TableBox.java:1516) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox.calcMinMaxWidth(TableBox.java:158) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.newtable.TableBox.layout(TableBox.java:221) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild0(BlockBoxing.java:321) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.layout.BlockBoxing.layoutBlockChild(BlockBoxing.java:299) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.layout.BlockBoxing.layoutContent(BlockBoxing.java:90) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.layoutChildren(BlockBox.java:1057) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:911) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.render.BlockBox.layout(BlockBox.java:827) ~[openhtmltopdf-core-0.0.1-RC18.jar:na]
	at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.layout(PdfBoxRenderer.java:332) ~[openhtmltopdf-pdfbox-0.0.1-RC18.jar:na]

@danfickle
Copy link
Owner

Thanks @svenfrauen for finding the cause. I think this is a side effect of fixing #328. I didn’t think to test with a broken image link. I will fix, add test and do another release.

Have a good holiday @rototor!

danfickle added a commit that referenced this issue Mar 17, 2019
Currently broken image links are causing a NPE.
danfickle added a commit that referenced this issue Mar 17, 2019
@danfickle
Copy link
Owner

All fixed. RC19 planned for tomorrow. Thanks again.

danfickle added a commit that referenced this issue Mar 17, 2019
@danfickle
Copy link
Owner

RC19 just released with this fix.

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