Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6386381

An NPE in XMLStreamWriterImpl

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 6
    • beta
    • xml
    • b78
    • generic
    • generic

      One of the JAX-WSA test case fails because of an NPE in XMLStreamWriterImpl line 1225 (highlighted below):

          void correctPrefix(QName attr1 , QName attr2){
              String tmpPrefix = null;
              QName decl = null;
              boolean done = false;
              
      *** if(attr1.prefix.equals(attr2.prefix) && !(attr1.uri.equals(attr2.uri))){
                  
                  tmpPrefix = fNamespaceContext.getPrefix(attr2.uri);

      Because attr1.uri is null. This seems to happen because of line 1186 (highlighted below):

              for(int i=0 ; i< fAttributeCache.size();i++){
                  attr = (Attribute)fAttributeCache.get(i);
                  for(int j=i+1;j<fAttributeCache.size();j++){
                      attr2 = (Attribute)fAttributeCache.get(j);
      *** if(attr.prefix == null && attr2.prefix != null)
                          correctPrefix(attr,attr2);
                  }
              }

      Sine this is an attribute, if attr.prefix==null, then the URI will be always null.
      Given the intention of this code, I suspect that the above line is a mistake of:

                      if(attr.prefix != null && attr2.prefix != null)

      ?

      (I confirmed that this fixes the problem. but there's a possibility that this could be a wrong way to fix a problem.)

            jsuttorsunw Jeff Suttor (Inactive)
            kkawagucsunw Kohsuke Kawaguchi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: