format source with scalafmt
This commit is contained in:
parent
0f40491d42
commit
ce404e4f53
1669 changed files with 43208 additions and 35404 deletions
|
|
@ -40,7 +40,6 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
|
||||
def toBinary(obj: AnyRef): Array[Byte] = obj match {
|
||||
case DaemonMsgCreate(props, deploy, path, supervisor) =>
|
||||
|
||||
def deployProto(d: Deploy): DeployData = {
|
||||
val builder = DeployData.newBuilder.setPath(d.path)
|
||||
|
||||
|
|
@ -72,9 +71,7 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
}
|
||||
|
||||
def propsProto = {
|
||||
val builder = PropsData.newBuilder
|
||||
.setClazz(props.clazz.getName)
|
||||
.setDeploy(deployProto(props.deploy))
|
||||
val builder = PropsData.newBuilder.setClazz(props.clazz.getName).setDeploy(deployProto(props.deploy))
|
||||
props.args.foreach { arg =>
|
||||
val (serializerId, hasManifest, manifest, bytes) = serialize(arg)
|
||||
builder.addArgs(ByteString.copyFrom(bytes))
|
||||
|
|
@ -85,12 +82,13 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
builder.build
|
||||
}
|
||||
|
||||
DaemonMsgCreateData.newBuilder.
|
||||
setProps(propsProto).
|
||||
setDeploy(deployProto(deploy)).
|
||||
setPath(path).
|
||||
setSupervisor(serializeActorRef(supervisor)).
|
||||
build.toByteArray
|
||||
DaemonMsgCreateData.newBuilder
|
||||
.setProps(propsProto)
|
||||
.setDeploy(deployProto(deploy))
|
||||
.setPath(path)
|
||||
.setSupervisor(serializeActorRef(supervisor))
|
||||
.build
|
||||
.toByteArray
|
||||
|
||||
case _ =>
|
||||
throw new IllegalArgumentException(
|
||||
|
|
@ -105,10 +103,12 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
val config =
|
||||
if (protoDeploy.hasConfig) {
|
||||
if (protoDeploy.hasConfigSerializerId) {
|
||||
serialization.deserialize(
|
||||
protoDeploy.getConfig.toByteArray,
|
||||
protoDeploy.getConfigSerializerId,
|
||||
protoDeploy.getConfigManifest).get.asInstanceOf[Config]
|
||||
serialization
|
||||
.deserialize(protoDeploy.getConfig.toByteArray,
|
||||
protoDeploy.getConfigSerializerId,
|
||||
protoDeploy.getConfigManifest)
|
||||
.get
|
||||
.asInstanceOf[Config]
|
||||
} else {
|
||||
// old wire format
|
||||
oldDeserialize(protoDeploy.getConfig, classOf[Config])
|
||||
|
|
@ -118,10 +118,12 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
val routerConfig =
|
||||
if (protoDeploy.hasRouterConfig) {
|
||||
if (protoDeploy.hasRouterConfigSerializerId) {
|
||||
serialization.deserialize(
|
||||
protoDeploy.getRouterConfig.toByteArray,
|
||||
protoDeploy.getRouterConfigSerializerId,
|
||||
protoDeploy.getRouterConfigManifest).get.asInstanceOf[RouterConfig]
|
||||
serialization
|
||||
.deserialize(protoDeploy.getRouterConfig.toByteArray,
|
||||
protoDeploy.getRouterConfigSerializerId,
|
||||
protoDeploy.getRouterConfigManifest)
|
||||
.get
|
||||
.asInstanceOf[RouterConfig]
|
||||
} else {
|
||||
// old wire format
|
||||
oldDeserialize(protoDeploy.getRouterConfig, classOf[RouterConfig])
|
||||
|
|
@ -131,10 +133,12 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
val scope =
|
||||
if (protoDeploy.hasScope) {
|
||||
if (protoDeploy.hasScopeSerializerId) {
|
||||
serialization.deserialize(
|
||||
protoDeploy.getScope.toByteArray,
|
||||
protoDeploy.getScopeSerializerId,
|
||||
protoDeploy.getScopeManifest).get.asInstanceOf[Scope]
|
||||
serialization
|
||||
.deserialize(protoDeploy.getScope.toByteArray,
|
||||
protoDeploy.getScopeSerializerId,
|
||||
protoDeploy.getScopeManifest)
|
||||
.get
|
||||
.asInstanceOf[Scope]
|
||||
} else {
|
||||
// old wire format
|
||||
oldDeserialize(protoDeploy.getScope, classOf[Scope])
|
||||
|
|
@ -159,25 +163,26 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
val manifest =
|
||||
if (protoProps.getHasManifest(idx)) protoProps.getManifests(idx)
|
||||
else ""
|
||||
serialization.deserialize(
|
||||
protoProps.getArgs(idx).toByteArray(),
|
||||
protoProps.getSerializerIds(idx),
|
||||
manifest).get
|
||||
serialization
|
||||
.deserialize(protoProps.getArgs(idx).toByteArray(), protoProps.getSerializerIds(idx), manifest)
|
||||
.get
|
||||
}
|
||||
} else {
|
||||
// message from an older node, which only provides data and class name
|
||||
// and never any serializer ids
|
||||
(proto.getProps.getArgsList.asScala zip proto.getProps.getManifestsList.asScala).iterator
|
||||
.map(oldDeserialize).to(immutable.Vector)
|
||||
proto.getProps.getArgsList.asScala
|
||||
.zip(proto.getProps.getManifestsList.asScala)
|
||||
.iterator
|
||||
.map(oldDeserialize)
|
||||
.to(immutable.Vector)
|
||||
}
|
||||
Props(deploy(proto.getProps.getDeploy), actorClass, args)
|
||||
}
|
||||
|
||||
DaemonMsgCreate(
|
||||
props = props,
|
||||
deploy = deploy(proto.getDeploy),
|
||||
path = proto.getPath,
|
||||
supervisor = deserializeActorRef(system, proto.getSupervisor))
|
||||
DaemonMsgCreate(props = props,
|
||||
deploy = deploy(proto.getDeploy),
|
||||
path = proto.getPath,
|
||||
supervisor = deserializeActorRef(system, proto.getSupervisor))
|
||||
}
|
||||
|
||||
private def serialize(any: Any): (Int, Boolean, String, Array[Byte]) = {
|
||||
|
|
@ -197,7 +202,8 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
"null"
|
||||
} else {
|
||||
val className = m.getClass.getName
|
||||
if (scala212OrLater && m.isInstanceOf[java.io.Serializable] && m.getClass.isSynthetic && className.contains("$Lambda$")) {
|
||||
if (scala212OrLater && m.isInstanceOf[java.io.Serializable] && m.getClass.isSynthetic && className.contains(
|
||||
"$Lambda$")) {
|
||||
// When the additional-protobuf serializers are not enabled
|
||||
// the serialization of the parameters is based on passing class name instead of
|
||||
// serializerId and manifest as we usually do. With Scala 2.12 the functions are generated as
|
||||
|
|
@ -222,8 +228,9 @@ private[akka] final class DaemonMsgCreateSerializer(val system: ExtendedActorSys
|
|||
private def oldDeserialize[T: ClassTag](data: ByteString, clazz: Class[T]): T = {
|
||||
val bytes = data.toByteArray
|
||||
serialization.deserialize(bytes, clazz) match {
|
||||
case Success(x: T) => x
|
||||
case Success(other) => throw new IllegalArgumentException("Can't deserialize to [%s], got [%s]".format(clazz.getName, other))
|
||||
case Success(x: T) => x
|
||||
case Success(other) =>
|
||||
throw new IllegalArgumentException("Can't deserialize to [%s], got [%s]".format(clazz.getName, other))
|
||||
case Failure(e) =>
|
||||
// Fallback to the java serializer, because some interfaces don't implement java.io.Serializable,
|
||||
// but the impl instance does. This could be optimized by adding java serializers in reference.conf:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue