Skip to content

Class Cast Exception when attempting to utilize Try<T>  #23

@kaseyreed

Description

@kaseyreed

Hi there,

We've run into an issue whereby, we receive a ClassCastException when attempting to use any fluent methods of CompletableFuture.

For example:

// Given a data loader like so:
MyDataLoader<String, Try<MyType>> myDataLoader = ...;

// The following code will throw a ClassCastException because we unwrap the Try<MyType> here
// https://github.com/graphql-java/java-dataloader/blob/master/src/main/java/org/dataloader/DataLoader.java#L323-L332
return myDataLoader(myId)
    .thenApply((Try<MyType> myPossibleValue) -> doSomethingWithValue(myPossibleValue));

The invocation of the thenApply method fails because there is a ClassCastException: unable to cast MyType to Try<MyType>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions