diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index dbaf013705..a9b74e071f 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -1237,7 +1237,7 @@ private[akka] case class RemoteActorRef private[akka] ( def postMessageToMailbox(message: Any, senderOption: Option[ActorRef]): Unit = RemoteClientModule.send[Any]( - message, senderOption, None, remoteAddress.get, timeout, true, this, None, actorType) + message, senderOption, None, remoteAddress.get, timeout, true, this, None, actorType, loader) def postMessageToMailboxAndCreateFutureResultWithTimeout[T]( message: Any, @@ -1245,7 +1245,7 @@ private[akka] case class RemoteActorRef private[akka] ( senderOption: Option[ActorRef], senderFuture: Option[CompletableFuture[T]]): CompletableFuture[T] = { val future = RemoteClientModule.send[T]( - message, senderOption, senderFuture, remoteAddress.get, timeout, false, this, None, actorType) + message, senderOption, senderFuture, remoteAddress.get, timeout, false, this, None, actorType, loader) if (future.isDefined) future.get else throw new IllegalActorStateException("Expected a future from remote call to actor " + toString) } diff --git a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala index 94661b9f1e..a22aa918cd 100644 --- a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala +++ b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala @@ -92,9 +92,10 @@ object ReflectiveAccess extends Logging { isOneWay: Boolean, actorRef: ActorRef, typedActorInfo: Option[Tuple2[String, String]], - actorType: ActorType): Option[CompletableFuture[T]] = { + actorType: ActorType, + loader: Option[ClassLoader] = None): Option[CompletableFuture[T]] = { ensureEnabled - clientFor(remoteAddress.getHostName, remoteAddress.getPort, None).send[T]( + clientFor(remoteAddress.getHostName, remoteAddress.getPort, loader).send[T]( message, senderOption, senderFuture, remoteAddress, timeout, isOneWay, actorRef, typedActorInfo, actorType) } } diff --git a/akka-remote/src/main/scala/akka/remote/MessageSerializer.scala b/akka-remote/src/main/scala/akka/remote/MessageSerializer.scala index b68bb0bca6..aca0333582 100644 --- a/akka-remote/src/main/scala/akka/remote/MessageSerializer.scala +++ b/akka-remote/src/main/scala/akka/remote/MessageSerializer.scala @@ -11,17 +11,18 @@ import akka.util._ import com.google.protobuf.{Message, ByteString} object MessageSerializer extends Logging { - private var SERIALIZER_JAVA: Serializer.Java = Serializer.Java - private var SERIALIZER_JAVA_JSON: Serializer.JavaJSON = Serializer.JavaJSON - private var SERIALIZER_SCALA_JSON: Serializer.ScalaJSON = Serializer.ScalaJSON - private var SERIALIZER_SBINARY: Serializer.SBinary = Serializer.SBinary - private var SERIALIZER_PROTOBUF: Serializer.Protobuf = Serializer.Protobuf + private def SERIALIZER_JAVA: Serializer.Java = Serializer.Java + private def SERIALIZER_JAVA_JSON: Serializer.JavaJSON = Serializer.JavaJSON + private def SERIALIZER_SCALA_JSON: Serializer.ScalaJSON = Serializer.ScalaJSON + private def SERIALIZER_SBINARY: Serializer.SBinary = Serializer.SBinary + private def SERIALIZER_PROTOBUF: Serializer.Protobuf = Serializer.Protobuf def setClassLoader(cl: ClassLoader) = { - SERIALIZER_JAVA.classLoader = Some(cl) - SERIALIZER_JAVA_JSON.classLoader = Some(cl) - SERIALIZER_SCALA_JSON.classLoader = Some(cl) - SERIALIZER_SBINARY.classLoader = Some(cl) + val someCl = Some(cl) + SERIALIZER_JAVA.classLoader = someCl + SERIALIZER_JAVA_JSON.classLoader = someCl + SERIALIZER_SCALA_JSON.classLoader = someCl + SERIALIZER_SBINARY.classLoader = someCl } def deserialize(messageProtocol: MessageProtocol): Any = { diff --git a/akka-remote/src/main/scala/akka/serialization/Serializer.scala b/akka-remote/src/main/scala/akka/serialization/Serializer.scala index e30e615322..20c91c8559 100644 --- a/akka-remote/src/main/scala/akka/serialization/Serializer.scala +++ b/akka-remote/src/main/scala/akka/serialization/Serializer.scala @@ -18,7 +18,7 @@ import sjson.json.{Serializer => SJSONSerializer} * @author Jonas Bonér */ @serializable trait Serializer { - var classLoader: Option[ClassLoader] = None + @volatile var classLoader: Option[ClassLoader] = None def deepClone(obj: AnyRef): AnyRef = fromBinary(toBinary(obj), Some(obj.getClass)) def toBinary(obj: AnyRef): Array[Byte]