Skip to content

Support Scala closure serialization #299

@asarkar

Description

@asarkar

See https://stackoverflow.com/q/47806670/839733 for details

case class TestRequest[T](app: String, locker: MeatLocker[T])

val factory: Stats => Unit = stats => {
  stats.app shouldBe (app)
  stats.unit shouldBe (SECONDS)
  stats.startupDurations should have length (10)
}

val locker: MeatLocker[Stats => Unit] = MeatLocker(factory)

val file = SerializationUtil.write(TestRequest[Stats => Unit](app, locker))
val state = SerializationUtil.read[TestRequest[Stats => Unit]](file)

(state.locker.get) (newStats())

Could not serialize lambda
java.lang.RuntimeException: Could not serialize lambda
at com.esotericsoftware.kryo.serializers.ClosureSerializer.write(ClosureSerializer.java:67)
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:651)
at com.twitter.chill.SerDeState.writeClassAndObject(SerDeState.java:64)
at com.twitter.chill.KryoPool.toBytesWithClass(KryoPool.java:116)
at com.twitter.chill.MeatLocker.(MeatLocker.scala:32)
at com.twitter.chill.MeatLocker$.apply(MeatLocker.scala:21)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions