I am trying to use a custom HTTP Status Code (450) but I get an error "org.springframework.http.HttpStatus doesn't have any enum constant '450' defined". I tried searching the other threads, but I wasn't able to find a suitable reply to my situation. Any help is greatly appreciated. Thanks!
Please find below my code:
<http:inbound-gateway supported-methods="POST"
request-channel="headerEnricher"
error-channel="errorHandlerRouterChannel"
reply-channel="responseChannel" header-mapper="headerMapper"
path="/testApi/1.0" request-payload-type="java.lang.String" />
Error handler method:
private Message<String> createErrorResponse() {
Map<String, String> respHeader = new HashMap<String, String>();
respHeader.put(HttpHeaders.STATUS_CODE, "450");
return MessageBuilder.withPayload("Validation Error")
.copyHeaders(respHeader).build();
}
Error Exception:
HTTP Status 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: No matching constant for [450]
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: No matching constant for [450]
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
root cause: java.lang.IllegalArgumentException: No matching constant for [450]
org.springframework.http.HttpStatus.valueOf(HttpStatus.java:426)
org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.resolveHttpStatusFromHeaders(HttpRequestHandlingEndpointSupport.java:549)
org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.setupResponseAndConvertReply(HttpRequestHandlingEndpointSupport.java:443)
org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:103)
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
javax.servlet.http.HttpServlet.service(HttpServlet.java:668)