Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2076035 | 5.0 | Ramesh Mandava | P3 | Resolved | Fixed | b30 |
Name: apR10229 Date: 10/17/2003
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b23"
JCK : 1.5
Platform[s] : Linux
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : N/A
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
public Document parse(DOMInput is)
throws DOMException
Parse an XML document from a resource identified by a DOMInput.
Parameters:
is - The DOMInput from which the source of the document is to be read. Returns:
If the DOMParser is a synchronous DOMParser, the newly created and populated Document is returned. If the DOMParser is asynchronous, null is returned since the document object may not yet be constructed when this method returns. Throws:
DOMException - INVALID_STATE_ERR: Raised if the DOMParser's DOMParser.busy attribute is true.
public Document parseURI(String uri)
throws DOMException
Parse an XML document from a location identified by a URI reference [IETF RFC 2396]. If the URI contains a fragment identifier (see section 4.1 in [IETF RFC 2396]), the behavior is not defined by this specification, future versions of this specification may define the behavior.
Parameters:
uri - The location of the XML document to be read. Returns:
If the DOMParser is a synchronous DOMParser, the newly created and populated Document is returned. If the DOMParser is asynchronous, null is returned since the document object may not yet be constructed when this method returns. Throws:
DOMException - INVALID_STATE_ERR: Raised if the DOMParser.busy attribute is true.
...
---------- end-of-excerpt ---------------
Problem description
===================
Methods org.w3c.dom.ls.DOMParser.parse() and org.w3c.dom.ls.DOMParser.parseURI() do not
raise an INVALID_STATE_ERR error when 'DOMParser.busy attribute is true'.
There's a minimized example below for method parse(). Method parseURI() is also affected.
Minimized test:
===============
------- Test.java -------
import java.io.*;
import org.w3c.dom.ls.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import org.w3c.dom.traversal.NodeFilter;
public class Test {
public static void main(String[] argv) {
Document doc = null;
try {
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = parser.parse(new StringBufferInputStream("<?xml version='1.0'?><ROOT/>"));
} catch (Throwable e) {
e.printStackTrace();
}
DOMImplementation impl = doc.getImplementation();
DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS","3.0");
DOMParser parser = implLS.createDOMParser(DOMImplementationLS.MODE_SYNCHRONOUS,null);
DOMInput src = implLS.createDOMInput();
src.setStringData("<ROOT><ELEMENT/></ROOR>");
ExceptionThrowerFilter filter = new ExceptionThrowerFilter(parser,src);
parser.setFilter(filter);
Document d = parser.parse(src);
System.out.println("getWhatToShow was called: "+filter.getWhatToShowCalled);
System.out.println("Exception was thrown: "+filter.exceptionWasThrown);
}
}
class ExceptionThrowerFilter implements DOMParserFilter {
DOMParser parser = null;
DOMInput src = null;
boolean exceptionWasThrown = false;
boolean getWhatToShowCalled = false;
public ExceptionThrowerFilter(DOMParser p, DOMInput s) {
parser = p;
src = s;
}
public short startElement(Element elt) {
return FILTER_ACCEPT;
}
public short acceptNode(Node enode) {
return FILTER_ACCEPT;
}
public int getWhatToShow() {
if (!getWhatToShowCalled) {
getWhatToShowCalled = true;
}
try {
Document d = parser.parse(src);
} catch(DOMException e) {
if (e.code == DOMException.INVALID_STATE_ERR) {
exceptionWasThrown = true;
} else {
e.printStackTrace();
}
}
return NodeFilter.SHOW_ALL;
}
}
------- end-of-Test.java -------
Minimized test output:
======================
<pav@hammer(pts/6).265> java Test
getWhatToShow was called: true
Exception was thrown: false
JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
Specific Machine Info:
=====================
Linux hammer 2.4.21 #1 Wed Jun 25 20:18:22 MSD 2003 i686 unknown
======================================================================
- backported by
-
JDK-2076035 Methods DOMParser.parse(), DOMParser.parseURI() don't raise INVALID_STATE_ERR
-
- Resolved
-