I am trying to upgrade my existing code to java 17 , but I am getting an error while trying to return the bearer token response. The onStatus method is giving compilation error but it was working fine in Java 11 . Below is the code
Mono<AppResponse> bearer = null;
WebClient cl = WebClient.builder().baseUrl(someUrl).defaultHeader(HttpHeaders.CONTENT_TYPE,"application/x-www-form-urlencoded").build();
var myUri = cl.post();
var mySpec = myUri.uri(UriBuilder::build);
var keyMap = new LinkedMultiValueMap<>();
keyMap.add("client_sc",cl);
............
var oneSpec = mySpec.bodyValue(map);
bearer = oneSpec.retrieve().
onStatus(HttpStatus::isError,response ->, // The problem is here , i am getting "The type HttpStatus does not define isError(HttpStatusCode) defined here "
response.bodyToMono(String.class).map(e-> {
log.error("There is Error ",e);
thrwo new MyAppException(
.....
}))).bodyToMono(AppResponse.class);
return bearer;
The above code was working perfectly in Java 11 , i am not able to understand what is going wrong here.
.*imports in your source file? Maybe one of those packages now has a newHttpStatusclass, so the wrong one is referenced here.isErrormethod didn't exist. If you ctrl-clickHttpStatusin your IDE, where does it lead you? Which jar file contains the class it sees?