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

Added Promise.then method for handling cases where the value is Void … #1

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

Conversation

kitschen
Copy link

…(notably in allOf), as this was breaking GWT)

@kitschen
Copy link
Author

More precisely, the issue appears in this situation:
Code in compiling with GWT:


        CompletableFuture<String> ft1 = new CompletableFuture<>();
        CompletableFuture<String> ft2 = new CompletableFuture<>();
        CompletableFuture<Void> all = CompletableFuture.allOf(ft1, ft2);
        all.whenComplete((value,reason) -> {
            logger.log(Level.SEVERE, "Received " + value + " " + reason);
        });
        ft1.complete("Hello");
        ft2.complete("World");
        // expecting the whenComplete to print "Received null null"

Instead of prrint, we get a stacktrace in the Javascript console

Uncaught (in promise) Error: java.lang.ClassCastException
    at ClassCastException_2_g$.createError_0_g$ [as createError_2_g$] (Throwable.java:117)
    at ClassCastException_2_g$.initializeBackingError_0_g$ [as initializeBackingError_1_g$] (Throwable.java:109)
    at ClassCastException_2_g$.Throwable_3_g$ (Throwable.java:69)
    at ClassCastException_2_g$.Exception_3_g$ (Exception.java:29)
    at ClassCastException_2_g$.RuntimeException_3_g$ (RuntimeException.java:29)
    at new ClassCastException_2_g$ (ClassCastException.java:27)
    at checkCriticalType_1_g$ (InternalPreconditions.java:154)
    at checkType_1_g$ (InternalPreconditions.java:138)
    at checkType_0_g$ (InternalPreconditions.java:133)
    at castTo_0_g$ (Cast.java:75)
    at CompletableFuture$lambda$2$Type_1_g$.accept_25_g$ [as accept_120_g$] (CompletableFuture.java:94)
    at lambda$1_3_g$ (NativePromiseImpl.java:57)
    at Function.onSettled_0_g$ (NativePromiseImpl.java:57)
    at lambda_0_g$ (Runtime.java:166)```

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.

1 participant