Extract/Subscribe to Mono value for return type on generated interface method

I have an interface that I am implementing that is generated from a WSDL, so I can’t change the signatures. One of the methods returns a List<Attributes> with Attributes being another WSDL generated class. The call flow has been updated to be reactive, and the Mono is bubbled all the way up the chain to this implementing class.

public List<Attributes> getUserProfile(final String filterValue);

The return statement calls a method that returns a Mono<UserProfile> which is then passed to another method that returns the List, but I cannot figure out how to subscribe to this to get the List so that my code compiles and works in a non-blocking way?

@Override
public List<Attributes> getUserProfile(final String filterValue) {

    return getUserProfile(serviceName, filterValue)
            .map(userProfile -> userProfileToAttributeList(userProfile));
//            .subscribe(userProfile -> userProfileToAttributeList(userProfile));
//            .map(listAttributes -> listAttributes);

//    Mono<UserProfile> userProfileMono = getUserProfile(serviceName, filterValue);
//    return userProfileMono.subscribe(userProfile -> userProfileToAttributeList(userProfile));
}

private Mono<UserProfile> getUserProfile(final String serviceName,final String filterValue) {
    return myService.getUserProfile(serviceName, filterValue);
}

private List<Attributes> userProfileToAttributeList(final UserProfile userProfile) {
    return userProfile.getAttributes().stream().map(MyServiceEndpoint::newAttribute).collect(Collectors.toList());
}

Answer

Since you can’t change the method signature to return Mono or Flux there is no other way around it, you need to block to get the “real” List<Attributes>.

Reactive only works if the complete operation is reactive on each step. Since this method “says” it will return List<Attributes> and not “promises” to return a List<Attributes> at some point in the future when needed and requested you have no option here.