Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future fix NPE, fast path for completed, fewer lines #4958

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

magicprinc
Copy link
Contributor

@magicprinc magicprinc commented Nov 19, 2023

  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
Copy link
Contributor Author

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

@vietj
Copy link
Member

vietj commented Nov 26, 2023

thanks for reporting the NPE @magicprinc

@magicprinc
Copy link
Contributor Author

magicprinc commented Nov 26, 2023

@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
Copy link
Contributor Author

@vietj and "happy path" for already completed Futures

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants