vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

Future fix NPE, fast path for completed, fewer lines

Open magicprinc opened this issue 2 years ago • 4 comments

  1. NPE
} catch (InterruptedException e) {
      Utils.throwAsUnchecked(e.getCause());

could cause NPE

  1. if Future.isComplete() simply return result

  2. ugly 2 lines

Utils.throwAsUnchecked(cause());
return null;

looks ugly, can be easily optimized

magicprinc avatar Nov 19 '23 17:11 magicprinc

@vietj NPE is real. There is a test in PR

magicprinc avatar Nov 24 '23 15:11 magicprinc

thanks for reporting the NPE @magicprinc

vietj avatar Nov 26 '23 13:11 vietj

@vietj Any chance to have in addition public static <E extends Throwable> RuntimeException throwAsUnchecked(Throwable t) throws E { instead of public static <E extends Throwable> void throwAsUnchecked(Throwable t) throws E {

Please… 🙏😅

The Pain Of Perfectionism, you know 🤦‍♂️

magicprinc avatar Nov 26 '23 16:11 magicprinc

@vietj and "happy path" for already completed Futures

default T await() {
   if (isComplete()) {
      return ...
    }

magicprinc avatar Nov 26 '23 16:11 magicprinc