Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Lazy future transforms are not called if the future is already completed #68

Open

Description

@alechenninger

Hasn't been a problem in practice by nature of their laziness, but this should be fixed. Shouldn't be hard.

Activity

  1. dcrissman commented on Nov 9, 2016

    @dcrissman
    Member

    Is this because if (isDone()) return; happens first in the complete methods on LazyTransformingFuture and LazyTransformableFuture?

  2. alechenninger commented on Nov 12, 2016

    @alechenninger
    ContributorAuthor

    No, if you look here:

    @Override
    public <V> TransformableFuture<V> transformSync(FutureTransform<U, V> futureTransform) {
        LazyTransformingFuture<U, V> future =
                new LazyTransformingFuture<>(futureTransform, completer);
        next.add(future);
        return future;
    }

    All this does is add it to the list of next futures to complete once we have a result.

    What if we already have a result? The newly added futures will never be completed.

    So in this method, we need to atomically check if the future is already completed, and in that case just complete the passed in future immediately, synchronously. Otherwise, add it to next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions