0

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.

3
  • 1
    Do you have any .* imports in your source file? Maybe one of those packages now has a new HttpStatus class, so the wrong one is referenced here. Commented Apr 19, 2023 at 18:47
  • @JoachimSauer no i have org.springframework.http.HttpStatus as the import Commented Apr 22, 2023 at 17:48
  • Then please reduce your problem to a minimal reproducible example that demonstrates the problem and edit your question to include that. My only other suspicion is that you somehow pulled in an old version of spring-web (4.x) where the isError method didn't exist. If you ctrl-click HttpStatus in your IDE, where does it lead you? Which jar file contains the class it sees? Commented Apr 22, 2023 at 22:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.