Making sure RemoteActorRef.loader is passed into RemoteClient, also adding volatile flag to classloader in Serializer to make sure changes are propagated crossthreads
This commit is contained in:
parent
5624e6d3aa
commit
06f230e7d4
4 changed files with 16 additions and 14 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import sjson.json.{Serializer => SJSONSerializer}
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
@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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue