0

Why resttemplate is not throwing UnknownHttpStatusCodeException but "java.lang.IllegalArgumentException: No matching constant for [0] while using RestTemplate" when an unknown http status code is received?

eg: when RestTemplate.exchange() method returns an unknown (or custom) HTTP status code, it is supposed to throw UnknownHttpStatusCodeException but actually I found that it returns java.lang.IllegalArgumentException: No matching constant for [0].

Sukh
  • 424
  • 5
  • 16
  • 1
    I wanted to help you out on a Friday night but I dont have anything to work with here. Please be more descriptive of your issue and try posting code samples. Welcome to the community. – Shantanu Wagh Dec 18 '21 at 04:42
  • Just added more description. @ShantanuWagh please have a look. – Sukh Dec 18 '21 at 19:49
  • Here should be a good pointer to know how spring handles it: https://www.tabnine.com/code/java/classes/org.springframework.web.client.UnknownHttpStatusCodeException. If the status resolves to null, then it throws `UnknownHttpStatusCodeException`, I think it is throwing `IllegalArgumentException` while resolving – Shantanu Wagh Dec 20 '21 at 16:08
  • So do you think it is a bug? Where it could be resolving this? I am not resolving in my code , Just running a test case with some unknown status code and in the exception block it is coming IllegalArgumentException. – Sukh Dec 21 '21 at 18:40
  • Cant help much without seeing the code. – Shantanu Wagh Jan 22 '22 at 03:43

0 Answers0