RFR: 8354774: DocumentBuilderFactory getAttribute throws NPE [v2]

Andrey Turbanov aturbanov at openjdk.org
Mon Apr 21 08:13:43 UTC 2025


On Fri, 18 Apr 2025 21:26:23 GMT, Joe Wang <joehw at openjdk.org> wrote:

>> Fix a NPE on calling DocumentBuilderFactory::getAttribute, refer to the bug report.
>> 
>> Also in this patch: consolidates get and set properties to use the same Util methods to reduce potential errors when code changes.
>> 
>> Test:
>>     Tier1 - 3 passed
>>     JCK test passed
>
> Joe Wang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   remove unused variable pName; remove unused imports

src/java.xml/share/classes/jdk/xml/internal/JdkXmlUtils.java line 133:

> 131:             String property) {
> 132:         String value = null;
> 133:         if  (xsm != null && (value = xsm.getLimitAsString(property)) != null) {

Suggestion:

        if (xsm != null && (value = xsm.getLimitAsString(property)) != null) {

test/jaxp/javax/xml/jaxp/unittest/common/PropertiesTest.java line 128:

> 126:             case DOM:
> 127:                 DocumentBuilderFactory dbf = DocumentBuilderFactory.newDefaultInstance();
> 128:                 if (apiValue != null)  dbf.setAttribute(apiProperty, apiValue);

Suggestion:

                if (apiValue != null) dbf.setAttribute(apiProperty, apiValue);

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24732#discussion_r2052113086
PR Review Comment: https://git.openjdk.org/jdk/pull/24732#discussion_r2052112697


More information about the core-libs-dev mailing list