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 shallowClone().toString() due to lack of parent #1410

Closed
wnm3 opened this issue Jul 1, 2020 · 2 comments
Closed
Labels
bug Confirmed bug that we should fix fixed
Milestone

Comments

@wnm3
Copy link

wnm3 commented Jul 1, 2020

I am using 1.13.1 org.jsoup.jsoup and have code like this:

String nodeHTML = ((Element) node).shallowClone().toString();

and get a NPE because Element.isInlineable at 1619 calls parent().isBlock() but a shallowClone has no parent.

Suggest revising test to be && (parent() == null || parent().isBlock()) rather than just parent().isBlock() since the latter causes NPE (unless no parents is not Inlineable...)

@gtaborcrossword
Copy link

Also toString() (internally outerHtml()) fails on this. So it seems to be a serious problem.

@jhy
Copy link
Owner

jhy commented Dec 22, 2020

Thanks all. This was fixed with 77fcaf4. In particular, adding the nullability annotations created a warning for this issue.

@jhy jhy added this to the 1.14.1 milestone Dec 22, 2020
@jhy jhy added the bug Confirmed bug that we should fix label Dec 22, 2020
@jhy jhy added the fixed label Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug that we should fix fixed
Projects
None yet
Development

No branches or pull requests

3 participants