=act,rem #13946 fix handling of null parameters in Props
+ Props creation with nulls does not fail any longer + null values are now serialised properly and can be used in remote deployments too + added tests for Reflect.findConstructor > does not change wire protocol, so that's open for discussion (if we > want it to be more like SerialisedMessage or not) Resolves #13946
This commit is contained in:
parent
dd71de5f93
commit
f13d4975cc
6 changed files with 166 additions and 10 deletions
|
|
@ -54,7 +54,7 @@ private[akka] class DaemonMsgCreateSerializer(val system: ExtendedActorSystem) e
|
|||
.setClazz(props.clazz.getName)
|
||||
.setDeploy(deployProto(props.deploy))
|
||||
props.args map serialize foreach builder.addArgs
|
||||
props.args map (_.getClass.getName) foreach builder.addClasses
|
||||
props.args map (a ⇒ if (a == null) "null" else a.getClass.getName) foreach builder.addClasses
|
||||
builder.build
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ private[akka] class DaemonMsgCreateSerializer(val system: ExtendedActorSystem) e
|
|||
import scala.collection.JavaConverters._
|
||||
val clazz = system.dynamicAccess.getClassFor[AnyRef](proto.getProps.getClazz).get
|
||||
val args: Vector[AnyRef] = (proto.getProps.getArgsList.asScala zip proto.getProps.getClassesList.asScala)
|
||||
.map(p ⇒ deserialize(p._1, system.dynamicAccess.getClassFor[AnyRef](p._2).get))(collection.breakOut)
|
||||
.map(deserialize)(collection.breakOut)
|
||||
Props(deploy(proto.getProps.getDeploy), clazz, args)
|
||||
}
|
||||
|
||||
|
|
@ -106,6 +106,10 @@ private[akka] class DaemonMsgCreateSerializer(val system: ExtendedActorSystem) e
|
|||
|
||||
protected def serialize(any: Any): ByteString = ByteString.copyFrom(serialization.serialize(any.asInstanceOf[AnyRef]).get)
|
||||
|
||||
protected def deserialize(p: (ByteString, String)): AnyRef =
|
||||
if (p._1.isEmpty && p._2 == "null") null
|
||||
else deserialize(p._1, system.dynamicAccess.getClassFor[AnyRef](p._2).get)
|
||||
|
||||
protected def deserialize[T: ClassTag](data: ByteString, clazz: Class[T]): T = {
|
||||
val bytes = data.toByteArray
|
||||
serialization.deserialize(bytes, clazz) match {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue