RFR: 8256515: javax.xml.XMLEventReader produces incorrect START_DOCUMENT event [v3]
Joe Wang
joehw at openjdk.java.net
Mon Dec 7 17:40:16 UTC 2020
On Sat, 5 Dec 2020 12:02:26 GMT, Marius Volkhart <github.com+1709517+MariusVolkhart at openjdk.org> wrote:
>> The default implementation of javax.xml.stream.XMLEventReader produced a StartDocument event that always indicated that the "standalone" attribute was set.
>>
>> The root cause of this was that the com.sun.xml.internal.stream.events.XMLEventAllocatorImpl always set the "standalone" attribute, rather than asking streamReader.standaloneSet() before setting the property of the StartDocumentEvent being created.
>
> Marius Volkhart has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:
>
> - Adjust test so it works with jtreg
> - Fix: javax.xml.stream.XMLEventReader produces incorrect START_DOCUMENT event
>
> The default implementation of javax.xml.stream.XMLEventReader produced a StartDocument event that always indicated that the "standalone" attribute was set.
>
> The root cause of this was that the com.sun.xml.internal.stream.events.XMLEventAllocatorImpl always set the "standalone" attribute, rather than asking streamReader.standaloneSet() before setting the property of the StartDocumentEvent being created.
> - Add test for XmlInputFactory
src/java.xml/share/classes/com/sun/xml/internal/stream/events/XMLEventAllocatorImpl.java line 136:
> 134: if (streamReader.standaloneSet()) {
> 135: sdEvent.setStandalone(streamReader.isStandalone());
> 136: }
The change looked fine at the first glance. However, when I looked at your test, I noticed that in your first test case, isStandalone will return true. This is because standalone was initiated as true and with the added condition, setStandalone is skipped.
To fix the issue, consider, instead of making it conditional, adding standaloneSet to the setStandalone method.
Pls update the copyright year at line 2, e.g. 2016 -> 2020.
test/jdk/javax/xml/jaxp/8256515/XmlInputFactoryTest.java line 22:
> 20:
> 21: @Test
> 22: void startDocumentEvent_standaloneSet() throws XMLStreamException {
Instead of creating a new test, add this test case to:
test/jaxp/javax/xml/jaxp/unittest/stream/XMLEventReaderTest/EventReaderTest.java
update the copyright year: add "2020,"
update class description: add 8256515 to the bug tag: @bug 8204329 8256515
change the name of the test case to sth like: testStandaloneSet
test/jdk/javax/xml/jaxp/8256515/XmlInputFactoryTest.java line 25:
> 23: var factory = XMLInputFactory.newInstance();
> 24: var xml = """
> 25: <?xml version="1.0"?>""";
There are three test cases here. Let's use DataProvider, sth. like {"<?xml version='1.0'?>", false, false}. The test then will take three parameters, e.g. xml, standalone, standaloneSet, and make two assertEquals
-------------
PR: https://git.openjdk.java.net/jdk/pull/1056
More information about the core-libs-dev
mailing list