You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by ne...@locus.apache.org on 2000/11/07 02:26:32 UTC

cvs commit: xml-soap/java/src/org/apache/soap/util/xml QName.java

neyama      00/11/06 17:26:31

  Modified:    java/src/org/apache/soap/util/xml QName.java
  Log:
  Bug fix for the following NullPointerException:
  -----------------
  A NullPointerException is thrown in unmarshalling an XML in which SOAP
  Body element has "Id" attribute. I'm wondering setting an "Id"
  attribute is allowed according to the schema of SOAP, because SOAP Body
  element allows any attribute.
  
  The environment is:
     Apache SOAP: The latest version in CVS
     Xerces 1.2.0
  
  The reason seems to be that the namespace URI of "Id" attribute is null.
  The exception was as follows:
  --------- Begin exception
  Exception in thread "main" java.lang.NullPointerException
  	at org.apache.soap.util.xml.QName.setNamespaceURI(QName.java:108)
  	at org.apache.soap.util.xml.QName.<init>(QName.java:102)
  	at org.apache.soap.AttributeHandler.unmarshall(AttributeHandler.java:231)
  	at org.apache.soap.Body.unmarshall(Body.java:183)
  	at org.apache.soap.Envelope.unmarshall(Envelope.java:243)
  	at test.main(test.java:11)
  --------- End exception
  
  The test program that causes the NullPointerException is as follows:
  --------- Begin test program
  import java.io.*;
  
  import org.w3c.dom.Document ;
  import org.apache.soap.Envelope ;
  import org.apache.soap.util.xml.XercesParserLiaison ;
  
  public class test {
      public static void main(String[] args) throws Exception {
          String xml ="<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body Id=\"body\"></s:Body></s:Envelope>";
          Document dom = new XercesParserLiaison().read("test", new StringReader(xml)) ;
          Envelope.unmarshall(dom.getDocumentElement()) ;
      }
  }
  --------- End test program
  
  Revision  Changes    Path
  1.5       +1 -1      xml-soap/java/src/org/apache/soap/util/xml/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/xml/QName.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- QName.java	2000/09/04 21:37:29	1.4
  +++ QName.java	2000/11/07 01:26:30	1.5
  @@ -105,7 +105,7 @@
     
     public void setNamespaceURI(String namespaceURI)
     {
  -    this.namespaceURI = namespaceURI.intern();
  +    this.namespaceURI = (namespaceURI == null ? "" : namespaceURI).intern();
     }
   
     public String getNamespaceURI()