1

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:

Question 1

Question 2

Question 3

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);
    }

}
Nick Div
  • 5,338
  • 12
  • 65
  • 127
  • There were fixes regarding hanging up in later version, can you upgrade to 8.5.51? – Ori Marko Feb 24 '20 at 13:50
  • Sure thing, I can try that – Nick Div Feb 24 '20 at 13:58
  • great, update if it helped – Ori Marko Feb 24 '20 at 14:00
  • @user7294900 It didnt do anything to help :( – Nick Div Feb 25 '20 at 20:35
  • There should be some thread block that might be happening in your PUT method execution. Did you try putting logger statements to see if there is any thread block that is happening. – himanshu_mps Mar 02 '20 at 08:58
  • @himanshu_mps Yes, I've added that as well but the server doesn't even log the request. – Nick Div Mar 02 '20 at 13:06
  • Can you post a version of your controller that will allow others to get a closer look, please? Are you indeed sending a legal PUT request? – Adrian M. Mar 02 '20 at 13:41
  • @AdrianM. Hello Adrian, I have posted my Controller code as well in the question. Yes its a legal PUT request and I have also mentioned in my post that it works for a few days after restarting the server without any issues. Its only after sitting idle for a bit that it starts acting out. – Nick Div Mar 02 '20 at 17:49
  • The only thing that I think is not needed is the @ResponseBody annotation but that will not make any difference. – himanshu_mps Mar 03 '20 at 04:23
  • @himanshu_mps Yeah that might be a good coding practice but doesn't help with my situation :( – Nick Div Mar 03 '20 at 06:08

0 Answers0