From d5c7e12787b2fa55d77f1f2580b1c7f87a705045 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 18 Apr 2011 16:26:31 +0200 Subject: [PATCH] Adding possibility to use akka.japi.Option in remote typed actor --- .../akka/remote/netty/NettyRemoteSupport.scala | 2 +- .../src/main/scala/akka/actor/TypedActor.scala | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala index 64e26cfdf5..8781c72ecd 100644 --- a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala +++ b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala @@ -1299,4 +1299,4 @@ class DefaultDisposableChannelGroup(name: String) extends DefaultChannelGroup(na throw new IllegalStateException("ChannelGroup already closed, cannot add new channel") } } -} +} \ No newline at end of file diff --git a/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala b/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala index 800385545b..7103c3fd5b 100644 --- a/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala +++ b/akka-typed-actor/src/main/scala/akka/actor/TypedActor.scala @@ -996,14 +996,20 @@ private[akka] abstract class ActorAspect { None) //TODO: REVISIT: Use another classloader? if (isOneWay) null // for void methods + else if (future.isEmpty) throw new IllegalActorStateException("No future returned from call to [" + joinPoint + "]") else if (TypedActor.returnsFuture_?(methodRtti)) future.get + else if (TypedActor.returnsOption_?(methodRtti)) { + import akka.japi.{Option => JOption} + future.get.await.resultOrException.as[JOption[AnyRef]] match { + case None => JOption.none[AnyRef] + case Some(x) if ((x eq null) || x.isEmpty) => JOption.some[AnyRef](null) + case Some(x) => x + } + } else { - if (future.isDefined) { - future.get.await - val result = future.get.resultOrException - if (result.isDefined) result.get - else throw new IllegalActorStateException("No result returned from call to [" + joinPoint + "]") - } else throw new IllegalActorStateException("No future returned from call to [" + joinPoint + "]") + val result = future.get.await.resultOrException + if(result.isDefined) result.get + else throw new IllegalActorStateException("No result returned from call to [" + joinPoint + "]") } }