Recently I've started seeing this weird issue with Tomcat. I have a small Spring MVC application(web-service) running on it which works fine except for PUT requests. All POST, GET etc requests are working fine when submitted to the server but only PUT requests are hanging up with a response of 504. I do not even see the request logged in the catalina.out.
When I restart the Tomcat it seems to fix the issue but when its idle for a while it starts acting up again.
I would really appreciate some help with this issue and please let me know if there is any other information that you would like me to post along with the question.
Just a note, there is nothing changed in the default configuration of the Tomcat. Version is Apache Tomcat/8.5.31
Also I tried to find some solution on SO for this issue and most of the users point towards the DB connection pool being the problem in a situation like this but I have POST and GET working fine which also connect to the DB. I am just confused why only PUT requests are failing.
Here are some questions that I have gone through:
Here is my controller(with other request mappings removed):
@RestController
public class EmployeeController {
private final EmployeeService employeeService;
@Autowired
public EmployeeController(EmployeeService employeeService) {
this.employeeService = employeeService;
}
@RequestMapping(value = "/employee/{employeeID}/{status}", method = RequestMethod.PUT,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<Void> updateStatus(@PathVariable Integer employeeID, @PathVariable String status) {
employeeService.updateStatus(employeeID, status);
return new ResponseEntity<>(HttpStatus.OK);
}
}