Springboot API выдает ошибку 500, но ошибки не регистрируются - PullRequest
1 голос
/ 27 мая 2020

У меня есть api springboot. Вызов одной из конечных точек из swagger выдает ошибку 500, но ничего не регистрируется. Когда я попробовал отладку, я увидел, что responseEntity заполняется непосредственно перед возвратом из контроллера. Следовательно, я чувствую, что код работает нормально. Даже тогда я вижу 500 в чванстве. Отсутствие логов затрудняет отладку. Кто-нибудь сталкивался с подобной проблемой? Как вы его решили? Конечная точка

выглядит так: Я добавил операторы журнала для справки

@RequestMapping(value = "/details/id/{id}", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"})
    public @ResponseBody
    ResponseEntity<Details> getDetailsById(@PathVariable(name="id")  @ApiParam(value ="id", example = "1234", required = true) String id) {
        inputValidation.validateInputAndThrowErrorIfNecessary(id);
        if(isBlank(id)) throw new IllegalArgumentException();

        Details details = detailsService.getDetailsById(id);

        if(details == null){
            logger.debug("Not found response..................");
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }
        logger.debug("Just before posting the response for  : {}", id);
        ResponseEntity<Details> responseEntity = new ResponseEntity<>(details, HttpStatus.OK);
        logger.debug("JSON--->\n"+responseEntity.toString()); // i see <200 OK OK,class Details { blah blah } at this point in logs

        return responseEntity;
    }

Когда я запускаю curl, ответ будет следующим:

curl -v GET "http://host:port/api/details/id/111" -H "accept: application/json;charset=UTF-8"
* Rebuilt URL to: GET/
* Could not resolve host: GET
* Closing connection 0
curl: (6) Could not resolve host: GET
*   Trying host...
* TCP_NODELAY set
* Connected to host (host) port port (#1)
> GET /api/details/id/111 HTTP/1.1
> Host: host:port
> User-Agent: curl/7.55.1
> accept: application/json;charset=UTF-8
>
< HTTP/1.1 500
< Content-Type: text/html;charset=utf-8
< Content-Language: en
< Content-Length: 455
< Date: Wed, 27 May 2020 00:49:11 GMT
< Connection: close
<
<!doctype html><html lang="en"><head><title>HTTP Status 500 ÔÇô Internal Server Error</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 500 ÔÇô Internal Server Error</h1></body></html>* Closing connection 1

...