RFR: 8049347: HTMLDocument throws NPE for Block Tag

Prasanta Sadhukhan psadhukhan at openjdk.org
Thu Jun 15 03:53:58 UTC 2023


On Wed, 14 Jun 2023 21:30:43 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Trying to iterate for HEAD HTML tag or for any other "Block" Tag results in NPE due to some spurious unhandled code which just return NULL.
>> Removing the code solves this problem and also does not cause any regression in clientlibs test.
>
> src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java line 550:
> 
>> 548:         if (t.isBlock()) {
>> 549:             // TBD
>> 550:             return null;
> 
> This doesn't look right to me. The comment suggests the implementation of something like `BlockIterator` is missing.
> 
> I would expect that iterator for `HTML.Tag.HEAD` returns all elements inside `<head>` element. Yet the comment for the `next` method
> 
> https://github.com/openjdk/jdk/blob/931625a9304ec2761ca9035d69fd33f6beadb124/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java#L1993-L1997
> 
> suggests, the iterator goes over all instances of the specified tag in the document.
> 
> What does the iterator return if you pass it `HTML.Tag.HEAD` or `HTML.Tag.P`?

It returns a LeafIterator object with HEAD or P tag respectively

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14466#discussion_r1230390783



More information about the client-libs-dev mailing list