NotImplementedError considered fatal?

113 views
Skip to first unread message

Jeff Olson

unread,
Feb 20, 2013, 2:03:54 PM2/20/13
to scala-l...@googlegroups.com
this bit of code:

val f = future { someExpensiveCalculation() }
Await.result(f, Duration.Inf)

left me twiddling my thumbs for quite some time. I know the "expensive calculation" can take awhile but surely it should complete or fail sooner or later.

no, it never does. it turns out that buried deep within someExpensiveCalculation() was a ??? (which throws a NotImplementedError). and for reasons unknown (to me anyway) a NotImplementedError is not considered to be a NonFatal exception (i.e. it is fatal). and in turns out that futures don't catch fatal exceptions, they just pass them up to the execution context. and so my future never completes. but of course its not really fatal. the default executor (ExecutionContext.global) just drops it on the floor without warning (apparently this has been fixed in 2.10.1-RC1) and keeps on chugging. so i'm left waiting forever wondering what's happening.

so why is NotImplementedError not considered NonFatal?

I would have much preferred the above future to complete with a Failure. Also in the context of Try, it seems like Try { ??? } should result in a Failure rather than throwing (at least in all the places I can think to use it).

-Jeff

Simon Schäfer

unread,
Feb 20, 2013, 2:22:18 PM2/20/13
to scala-l...@googlegroups.com
Just for reference, this was discussed before:
https://groups.google.com/forum/?fromgroups=#!topic/scala-user/nHQcTQibWI4
> --
> You received this message because you are subscribed to the Google
> Groups "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to scala-languag...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

√iktor Ҡlang

unread,
Feb 20, 2013, 4:09:31 PM2/20/13
to scala-l...@googlegroups.com
I totally agree. NotImplementedError is not fatal, I'm rooting to fix this at least for 2.11.



For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.





--
Viktor Klang
Director of Engineering

Typesafe - The software stack for applications that scale
Twitter: @viktorklang

Jeff Olson

unread,
Feb 20, 2013, 5:01:14 PM2/20/13
to scala-l...@googlegroups.com
Thanks for the link Simon. Whether or not futures should treat NonFatal exceptions differently than fatal ones is a very interesting question, although it seems somewhat orthogonal to whether or not this particular exception (NotImplementedError) should be considered NonFatal or not. Again I see no reason why it should not be NonFatal (in the context of Future, Try, or anywhere else NonFatal is used).

-Jeff

Som Snytt

unread,
Feb 20, 2013, 7:37:55 PM2/20/13
to scala-l...@googlegroups.com

The catchability of ??? was discussed at its introduction:

http://www.scala-lang.org/node/11113

-- whether "reasonable applications" should be fielding it.

I was just thinking that it's close to a LinkageError, but the thread says:

I reasoned that a failed assertion also gives an error, and a missing
implementation is closest to a failed assertion.

I see AssertionError is NonFatal, even though the JLS (for what it's worth) says "it is intended that it never be caught."

I'd forgotten this one:

Also, we obviously can't ship ??? without its complement.

def ¿¿¿(body: => Any) =
try { body; false }
catch { case _: NotYetImplementedException => true }

Will that be available in Paulpdef in 2.11?

martin odersky

unread,
Feb 21, 2013, 8:23:18 AM2/21/13
to scala-l...@googlegroups.com
I agree the arguments are very strong that ??? should be non-fatal.

 - Martin
Martin Odersky
Prof., EPFL and Chairman, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967

√iktor Ҡlang

unread,
Feb 21, 2013, 8:31:55 AM2/21/13
to scala-l...@googlegroups.com
On Thu, Feb 21, 2013 at 2:23 PM, martin odersky <martin....@epfl.ch> wrote:
I agree the arguments are very strong that ??? should be non-fatal.

I'll open a ticket for 2.11

Cheers,



--

√iktor Ҡlang

unread,
Feb 21, 2013, 9:34:08 AM2/21/13
to scala-l...@googlegroups.com

Jeff Olson

unread,
Feb 21, 2013, 10:26:43 AM2/21/13
to scala-l...@googlegroups.com
Awesome, thanks Viktor.
Reply all
Reply to author
Forward
0 new messages