Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinkedHashMap after deserialization has different ordering #5590

Closed
scabug opened this issue Mar 20, 2012 · 2 comments
Closed

LinkedHashMap after deserialization has different ordering #5590

scabug opened this issue Mar 20, 2012 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 20, 2012

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)
@scabug
Copy link
Author

scabug commented Mar 20, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5590?orig=1
Reporter: Jarosław Wosik (roeoender)
Affected Versions: 2.9.1, 2.10.0-M2

@scabug
Copy link
Author

scabug commented Mar 25, 2012

Jarosław Wosik (roeoender) said:
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.

@scabug scabug closed this as completed May 4, 2012
@scabug scabug added this to the 2.10.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants