Hi Daniel,

the UndeclaredThrowableException is sadly due to the change in
implementation of TypedActors from Akka 1.x to Akka 2.x and stem from the
fact that Dynamic Proxies in the JDK apply this behavior (checked
exceptions is a Java language feature and not a Java Runtime Feature, so
they wouldn't have to, but for some weird reason they chose to do it like
that).

Hence: You need to add @throws to get the original behavior.

Cheers,
√


On Tue, Jan 7, 2014 at 2:01 PM, Daniel Hobi <[email protected]> wrote:

> Hi there
>
> I'm currently migrating from Akka 1.x to 2.2.3 and stumbled across the
> following behaviour in TypedActor:
>
> trait Squarer {
>   def squareNow(i: Int): Int //blocking send-request-reply
> }
>
> class SquarerImpl extends Squarer {
>   def squareNow(i: Int): Int = throw new Exception("what??")
> }
>
> In Akka 1.x: My own java.lang.Exception is thrown
> In Akka 2.x: My own java.lang.Exception is encapsulated in the thrown
> java.lang.reflect.UndeclaredThrowableException
>
> To have the same behaviour in 1.x and 2.x, I need to annote the trait
> method(s) with @throws(classOf[XXX]) to declare that an exception might be
> thrown.
>
> trait Squarer {
>   @throws(classOf[Exception])
>   def squareNow(i: Int): Option[Int] //blocking send-request-reply
> }
>
> My questions:
> 1.
> Taken from http://doc.akka.io/docs/akka/2.2.3/scala/typed-actors.html
> "Any other type of value will use send-request-reply semantics, but 
> *will*block to wait for an answer, throwing
> java.util.concurrent.TimeoutException if there was a timeout *or rethrow
> any exception that was thrown during this call.*"
> Is this the intended behaviour (UndeclaredThrowableException)?
>
> 2. Is it "good practice" to throw exceptions in blocking
> send-request-reply methods in general or should it better be handled by
> other mechanisms like net.liftweb.common.Box?
>
> Thanks for your help!
> Daniel
>
>  --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Cheers,
√

*Viktor Klang*
*Director of Engineering*
Typesafe <http://www.typesafe.com/>

Twitter: @viktorklang

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to