DOM level 3 checks don't work properly
--------------------------------------

                 Key: WSCOMMONS-358
                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-358
             Project: WS-Commons
          Issue Type: Bug
          Components: XmlSchema
            Reporter: Daniel Kulp



In DOMUtils, there are methods like:
    public static String getInputEncoding(Document doc) {
        try {
            Method m = Document.class.getMethod("getInputEncoding", new 
Class[]{});
            return (String) m.invoke(doc, new Object[]{});
        } catch (Exception e) {
            return DEFAULT_ENCODING;
        }
    }

which supposedly check if it's a DOM level 3 thing or not.   However, that only 
checks if the API jar is DOM level 3.   It doesn't check the actual 
implementation.    If you end up with the level 3 api jar, but an older xerces, 
the Method is found on the Document class, but when invoke is called, it gets:
ava.lang.AbstractMethodError: 
weblogic.apache.xerces.dom.DeferredDocumentImpl.getInputEncoding()Ljava/lang/String;
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.apache.ws.commons.schema.utils.DOMUtil.getInputEncoding(DOMUtil.java:602)

Most likely, the catch Exception should be changed to Throwable, but it might 
be good to change:
Method m = Document.class.getMethod("getInputEncoding", new Class[]{});
to 
Method m = doc.getClass().getMethod("getInputEncoding", new Class[]{});
to get the method off the actual implementation class.




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to