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

Map.WithDefault is not serializable #5018

Closed
scabug opened this issue Sep 21, 2011 · 8 comments
Closed

Map.WithDefault is not serializable #5018

scabug opened this issue Sep 21, 2011 · 8 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Sep 21, 2011

Most of the collections lib is, and so it's pretty surprising that this isn't:

scala> Map(1 -> 1).withDefaultValue(1)
res9: scala.collection.immutable.Map[Int,Int] = Map(1 -> 1)

scala> import java.io._
import java.io._

scala> val buffer = new ByteArrayOutputStream
buffer: java.io.ByteArrayOutputStream = 

scala> val out = new ObjectOutputStream(buffer)
out: java.io.ObjectOutputStream = java.io.ObjectOutputStream@60232fff

scala> out writeObject res9
java.io.NotSerializableException: scala.collection.immutable.Map$WithDefault
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
	at .<init>(<console>:41)
	at .<clinit>(<console>)
	at $anonfun$1.apply(<console>:7)
	at $anonfun$1.apply(<console>:6)
	at scala.tools.nsc.interpreter.Phased$class.atCurrent(Phased.scala:71)
	at scala.tools.nsc.interpreter.Power$$anon$3.atCurrent(Power.scala:413)
	at .<init>(<console>:6)
	at .<clinit>(<console>)
	at $print(<console>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:775)
	at scala.tools.nsc.interpreter.IMain$Request$$anonfun$18.apply(IMain.scala:1039)
	at scala.tools.nsc.interpreter.Line.scala$tools$nsc$interpreter$Line$$runAndSetState(Line.scala:41)
	at scala.tools.nsc.interpreter.Line$$anonfun$2.apply$mcV$sp(Line.scala:47)
	at scala.tools.nsc.io.package$$anon$2.run(package.scala:22)
	at java.lang.Thread.run(Thread.java:722)
@scabug
Copy link
Author

scabug commented Sep 21, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5018?orig=1
Reporter: @dlwh
Affected Versions: 2.9.1

@scabug
Copy link
Author

scabug commented Oct 12, 2011

Evan Chan (velvia) said:
I have also hit this issue, please fix.

@scabug
Copy link
Author

scabug commented Dec 16, 2011

@acruise said:
Also ImmutableDefaultKeySet

@scabug
Copy link
Author

scabug commented Feb 16, 2012

@acruise said:
Also DefaultValuesIterable

@scabug
Copy link
Author

scabug commented Feb 19, 2012

Evil Ipos (evil.ipos) said:
It's any technical reason why this cannot be fixed? It's annoying to use "m map identity" to send serialized map via network (to use for example with Akka)

@scabug
Copy link
Author

scabug commented Apr 28, 2012

@soc said:
It seems like Map.WithDefault itself is not serializable, not some field/value of it (as I assumed first). So the fix would be to add Serializable to the right place. Right in the sense of either to the class itself or to a super class/trait. Not sure what's more correct.

@scabug scabug closed this as completed May 4, 2012
@scabug
Copy link
Author

scabug commented Mar 15, 2013

@nilskp said:
Just ran into this. Doesn't appear to have been backported to 2.9 against which it was filed.

@scabug
Copy link
Author

scabug commented Aug 19, 2015

@lrytz said:
fix was in scala/scala#471

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