Details

    • Type: Bug Bug
    • Status: In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.5
    • Fix Version/s: None
    • Component/s: runtime
    • Labels:
      None
    • Environment:

      JDK6u35, JDK7u7 Win7 64

      Description

      There is a bug in com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl

      NamespaceContextImpl reuses NamespaceContextImpl.Element objects to generate prefixes.
      NamespaceContextImpl.Element.setTagName(Name tagName, Object outerPeer) doesn't clean up NamespaceContextImpl.Element.elementLocalName
      When the element is reused in
      NamespaceContextImpl.declareNsUri(String uri, String preferedPrefix, boolean requirePrefix) {
      ...
      if (current.elementLocalName!=null)

      { // CHANGES A NAME TO THOSE LEFT FROM AN OTHER NODE!!! current.setTagName(size, current.elementLocalName, current.getOuterPeer()); }

      ...
      }

      Solution is to clean elementLocalName in

      public void setTagName( Name tagName, Object outerPeer ) {
      assert tagName!=null;
      this.elementName = tagName;
      this.elementLocalName = null; // +
      this.outerPeer = outerPeer;
      }

        Activity

        Hide
        Iaroslav Savytskyi added a comment -

        Hi,

        thank you for reporting. Can you please provide small test case how can I reproduce the problem.

        Thanks.

        Show
        Iaroslav Savytskyi added a comment - Hi, thank you for reporting. Can you please provide small test case how can I reproduce the problem. Thanks.
        Hide
        ratoo added a comment -

        Unfortunately I can't .
        Things works to me now and I did too much changes to figure out what was wrong.

        I had an adapter with a DOM Element returned.
        Somehow JAXB is parsing this element tree using localNames.
        IMHO it's obvious that either elementName or elementLocalName must be null.

        Cheers,

        D.

        Show
        ratoo added a comment - Unfortunately I can't . Things works to me now and I did too much changes to figure out what was wrong. I had an adapter with a DOM Element returned. Somehow JAXB is parsing this element tree using localNames. IMHO it's obvious that either elementName or elementLocalName must be null. Cheers, D.
        Hide
        ratoo added a comment - - edited

        Hello,

        I got the bug again and finally figured out what exactly happens.
        I have a QName attribute.
        When the default namespace is defined (i.e. xmlns="www.example.com") and
        my QName attribute has no namespace,
        NamespaceContextImpl tries to rearrange:

        > 188 // first, if the previous URI assigned to "" is
        > 189 // a "known URI", remember what we've reallocated
        > 190 // so that we can fix it when this context pops.
        ...
        > 202 if (current.elementLocalName!=null)

        { > 203 current.setTagName(size, current.elementLocalName, current.getOuterPeer()); > 204 }

        here it changes the tag name (current).
        setTagName has a bug - doesn't clean elementLocalName (as seen above).

        P.S. can't find a way to submit jUnit test code.
        https://java.net/projects/jaxb/lists/users/archive/2013-05/message/7

        Show
        ratoo added a comment - - edited Hello, I got the bug again and finally figured out what exactly happens. I have a QName attribute. When the default namespace is defined (i.e. xmlns="www.example.com") and my QName attribute has no namespace, NamespaceContextImpl tries to rearrange: > 188 // first, if the previous URI assigned to "" is > 189 // a "known URI", remember what we've reallocated > 190 // so that we can fix it when this context pops. ... > 202 if (current.elementLocalName!=null) { > 203 current.setTagName(size, current.elementLocalName, current.getOuterPeer()); > 204 } here it changes the tag name (current). setTagName has a bug - doesn't clean elementLocalName (as seen above). P.S. can't find a way to submit jUnit test code. https://java.net/projects/jaxb/lists/users/archive/2013-05/message/7

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            ratoo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: