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

LinkedHashMap after deserialization has different ordering

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.1, Scala 2.10.0-M2
    • Fix Version/s: Scala 2.10.0
    • Component/s: Collections
    • 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)
      

        Activity

        Hide
        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
        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:
            Aleksandar Prokopec
            Reporter:
            Jarosław Wosik
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development