JDK-8322214 : Return value of XMLInputFactory.getProperty() changed from boolean to String in JDK 22 early access builds
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.stream
  • Affected Version: 22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2023-12-15
  • Updated: 2024-01-08
  • Resolved: 2024-01-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22 JDK 23
22Fixed 23 masterFixed
Related Reports
Duplicate :  
Relates :  
Description
Apache POI uses XMLInputFactory for handling XML and a unit-test verifies that setting properties has the expected effect.

When running tests with JDK 22, there is a failure because  XMLInputFactory.getProperty() now returns the String "false", instead of Boolean.FALSE.

This looks like a change in behavior from JDK 21 to current JDK 22 early-access builds. Tested with JDK jdk-22-ea+18 and current jdk-22-ea+27.

The following simple unit-test works in JDK 8 - 21, but fails in early access builds of JDK 22 and JDK 23.

{noformat}
import static javax.xml.stream.XMLInputFactory.SUPPORT_DTD;
import static org.junit.jupiter.api.Assertions.assertFalse;

import javax.xml.stream.XMLInputFactory;

import org.junit.jupiter.api.Test;

public class TestXMLHelper {
    @Test
    public void testNewXMLInputFactory() {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty(SUPPORT_DTD, false);
        assertFalse((boolean)factory.getProperty(XMLInputFactory.SUPPORT_DTD));
    }
}
{noformat}

Since JDK 22 early access builds it fails with the following:

{noformat}
java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Boolean (java.lang.String and java.lang.Boolean are in module java.base of loader 'bootstrap')

	at org.apache.poi.util.TestXMLHelper.testNewXMLInputFactory(TestXMLHelper.java:32)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
{noformat}

Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk22/pull/32 Date: 2024-01-04 19:09:34 +0000
04-01-2024

Which JDK 22 change introduced this regression? It needs to be linked, in case anyone backports the regressing change.
04-01-2024

Changeset: 755722ce Author: Joe Wang <joehw@openjdk.org> Date: 2024-01-04 05:04:45 +0000 URL: https://git.openjdk.org/jdk/commit/755722ced60a686799c7f419feae61c04ce41f09
04-01-2024

Bisection points to JDK-8306632.
04-01-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17252 Date: 2024-01-03 19:31:16 +0000
03-01-2024