can you help me understand why you give me this warning?
Essentially this POST call gives me results (userPayload), that I reuse in a further POST call and save the data to db.
What's wrong?
public Mono<ResponseEntity> createUser(UserRequest requestPayload) {
return webClientBuilder
.build()
.post()
.uri(settings.getUrl())
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", settings.getApiToken())
.body(BodyInserters.fromValue(requestPayload))
.exchange()
.flatMap(clientResponse -> {
if (clientResponse.statusCode().isError()) {
return clientResponse.bodyToMono(Error.class)
.flatMap(error -> Mono.error(new CustomException(clientResponse.statusCode(), error)));
} else {
return clientResponse.bodyToMono(UserPayload.class)
.flatMap(user -> {
saveNewUser(user);
validateUser(user.getLinks());
return Mono.just(new ResponseEntity<>(user, HttpStatus.OK));
}).switchIfEmpty(Mono.error(new NotFoundCustomException("User Payload not found!")));
}
});
}
Second method:
private Mono validateUser(String uri) {
webClientBuilder
.build()
.post()
.uri(uri)
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", settings.getApiToken())
.retrieve()
.onStatus(HttpStatus::isError, clientResponse -> clientResponse.bodyToMono(Error.class)
.flatMap(error -> Mono.error(new CustomException(clientResponse.statusCode(), error)))
).bodyToMono(Void.class);
}