Closed GoogleCodeExporter closed 9 years ago
the magic here is that null implies the conversion failed and go ahead and
throw the exception
Original comment by adrian.f...@gmail.com
on 7 Jan 2010 at 2:08
looks like you guys implemented this:
http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/util/c
oncurrent/Futures.html#makeChecked%28java.util.concurrent.Future,%20com.google.c
ommon.base.Function%29
you can close this issue
Original comment by adrian.f...@gmail.com
on 28 Jul 2010 at 10:51
my mistake this isn't the same as makechecked. please keep this open
Original comment by fernc...@gmail.com
on 28 Jul 2010 at 11:14
I'm having a hard time wrapping my head around what exactly this would look
like. Can you be more specific in your request?
Original comment by fry@google.com
on 26 Jan 2011 at 10:34
sortof like this:
public static <T> ListenableFuture<T> coerceExceptions(ListenableFuture<T> in,
Function<Exception, T> coercer);
Original comment by fernc...@gmail.com
on 26 Jan 2011 at 10:38
In other words you want all exceptions to either be coerced into valid return
values, or else thrown as is?
Original comment by fry@google.com
on 28 Jan 2011 at 3:50
Right. Im flexible, but current behavior is to return null instead of throwing
in the function. This allows you to not have to declare checked exceptions.
The only tricky part is dealing with Void, as returning a valid Void object
looks awkward.
Original comment by adrian.f...@gmail.com
on 28 Jan 2011 at 3:58
Hehe. I ended up needing exactly the same thing.
Except I'd add an executor version (and maybe widen exception type), so:
Throwing exception in the function instead of returning 'null' seems more
adequate to me, what if my 'null' is a valid value?
What if my function throws a different exception? That has to be handled anyway.
public static <T> ListenableFuture<T> transformFailure(ListenableFuture<T> in,
Function<Throwable, T> fn);
public static <T> ListenableFuture<T> transformFailure(ListenableFuture<T> in,
Function<Throwable, T> fn, Executor executor);
Original comment by earwin@gmail.com
on 5 Jun 2011 at 1:57
Original comment by kevinb@google.com
on 13 Jul 2011 at 6:18
Original comment by fry@google.com
on 10 Dec 2011 at 3:42
Original comment by fry@google.com
on 16 Feb 2012 at 7:17
Original comment by kevinb@google.com
on 30 May 2012 at 7:43
Original comment by kevinb@google.com
on 22 Jun 2012 at 6:16
you can close this case, as FutureFallback does the trick
Original comment by fernc...@gmail.com
on 27 Dec 2012 at 4:28
How nice!
Original comment by kevinb@google.com
on 27 Dec 2012 at 8:21
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:16
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:10
Original issue reported on code.google.com by
fernc...@gmail.com
on 7 Jan 2010 at 1:39