Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-5590

LinkedHashMap after deserialization has different ordering

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1, Scala 2.10.0-M2
    • Fix Version/s: Scala 2.10.0
    • Component/s: None
    • Labels:
    • Environment:

      Windows Xp
      Welcome to Scala version 2.10.0-M2 (Java HotSpot(TM) Client VM, Java 1.5.0_22)

      Description

      Following code:

      	  val bos = new ByteArrayOutputStream()
      	  val out = new ObjectOutputStream(bos)
      	  out.writeObject(LinkedHashMap("a"->"a", "b"->"b", "c"->"c"));	  
      	  val arr = bos.toByteArray();
      	  val in = new ObjectInputStream(new ByteArrayInputStream(arr));
      	  val deser = in.readObject();
      	  println(deser)
      

      prints:

      Map(c -> c, a -> a, b -> b)
      

      while it should, maintain the original insertion order:

      Map(a -> a, b -> b, c -> c)
      

        Attachments

          Activity

          Hide
          roeoender Jarosław Wosik added a comment -

          It seems that LinkedHashMap should have it's own implementation of entriesIterator because the one inherited from HashTable doesn't take the element order into account. "entriesIterator" is used by LinkedHashMap.writeObject > serializeTo > foreachEntry.

          Show
          roeoender Jarosław Wosik added a comment - It seems that LinkedHashMap should have it's own implementation of entriesIterator because the one inherited from HashTable doesn't take the element order into account. "entriesIterator" is used by LinkedHashMap.writeObject > serializeTo > foreachEntry.

            People

            • Assignee:
              prokopec Aleksandar Prokopec
              Reporter:
              roeoender Jarosław Wosik
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: