Scala Programming Language
  1. Scala Programming Language
  2. SI-7074

scala.xml.Utility removes attributes when sorting.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.2
    • Component/s: XML Support
    • Environment:

      Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37)

      Description

      In 2.10.0 the Utility.sort(md: MetaData) function has broken. An example of when the problem occurs is below, it is for a case where alphabetically the first attribute comes after the proceeding attributes.

      REPL
      
      scala> val node:Node = <a d="1" b="2" c="3"></a>
      node: scala.xml.Node = <a d="1" b="2" c="3"></a>
      
      scala> Utility.sort(node)
      res8: scala.xml.Node = <a b="2" d="1"/> //attribute c is missing
      
      

      This works in 2.9.2 where the only difference in any of the sorting functions is in the MetaData sorting function. The value that is returned after sorting some attributes is:

      2.9.2 Utility.scala
      smaller.append( Null ).append(md.copy ( greater ))
      
      
      2.10.0 Utility.scala
      smaller.copy(md.copy ( greater ))
      
      

      In 2.10.0 omitting smaller.append( Null ) loses attributes in some cases. I believe this change should be reverted to 2.9.2.

        Activity

        Hide
        Alex Cruise added a comment - - edited

        Szabolcs, I namedropped you because I thought it was your fix that changed the behaviour between 2.9 and 2.10. My patch is no good, please ignore it.

        Show
        Alex Cruise added a comment - - edited Szabolcs, I namedropped you because I thought it was your fix that changed the behaviour between 2.9 and 2.10. My patch is no good, please ignore it.
        Hide
        Szabolcs Berecz added a comment -

        It's possible it was my fix that caused this bug. I will take a closer look this weekend.

        Show
        Szabolcs Berecz added a comment - It's possible it was my fix that caused this bug. I will take a closer look this weekend.
        Hide
        Szabolcs Berecz added a comment -
        Show
        Szabolcs Berecz added a comment - Pull request: https://github.com/scala/scala/pull/2149
        Hide
        A. P. Marki added a comment -

        Should be closed, fixed in 2.10.2?

        Show
        A. P. Marki added a comment - Should be closed, fixed in 2.10.2?
        Hide
        Matthew Pickering added a comment -

        Yes it's fixed we've moved to using 2.10.2.

        Show
        Matthew Pickering added a comment - Yes it's fixed we've moved to using 2.10.2.

          People

          • Assignee:
            Szabolcs Berecz
            Reporter:
            Matthew Pickering
          • Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development