传入的压缩POST请求属性为null

时间:2018-07-19 11:43:31

标签: java spring rest jackson gzip

我有一个带有简单RestController的Spring Boot 2项目。它提供了POST方法来获取一些信息并返回随机生成的ID。从Dropwizard(DW)客户端项目,我正在发送压缩的POST请求。不幸的是,传入对象及其属性为null。如果我将我的Spring项目替换为另一个具有相同功能的DW服务器项目,那么一切都会按预期进行,并且传入的对象不再为null。

我的Spring Boot 2 Restcontroller:

...
@RequestMapping(value = "/test_request", method = RequestMethod.POST,
        consumes = MediaType.APPLICATION_JSON_VALUE,
        produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<TaskId> generateTaskId(final Request request)
{
    logger.info("Incoming request with content "+ request.getContent());

    SecureRandom random = new SecureRandom();
    TaskId taskId = new TaskId(String.valueOf(random.nextInt(100000)));

    storage.put(taskId.getId(), Faker.fakeResponse(ResponseStatus.randomStatus()));

    logger.info("Stored Response with taskId " + taskId.getId());

    return new ResponseEntity<>(taskId, HttpStatus.OK);
} ...

我的application.yml:

server:
  port: 8090
  compression:
    enabled: true
    min-response-size: 1
    mime-types: application/json

logging.level.org.springframework.web: TRACE

DW项目(客户端)日志:

INFO  [2018-07-19 10:49:31,622] org.eclipse.jetty.server.Server: Started @1728ms
INFO  [2018-07-19 10:49:37,467] com.test.core.RequestListener: Received request with message ID 1573900971 for user admin
INFO  [2018-07-19 10:49:37,480] com.test.RequestHandler: Submitting request 1573900971 for user admin to SpringRestTest
INFO  [2018-07-19 10:49:37,569] OutboundRequestResponse: 1 * Sending client request on thread test-requests
1 > POST http://localhost:8090/fake/test_request
1 > Accept: application/json
1 > Content-Type: application/json


INFO  [2018-07-19 10:49:40,305] OutboundRequestResponse: 1 * Client response received on thread test-requests
1 < 200
1 < Content-Type: application/json;charset=UTF-8
1 < Date: Thu, 19 Jul 2018 10:49:40 GMT
1 < Transfer-Encoding: chunked
1 < Vary: Accept-Encoding
{"id":"70555"}

Spring项目(服务器)日志:

2018-07-19 12:49:37.628 DEBUG 6787 --- [nio-8090-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /fake/test_request
2018-07-19 12:49:37.628 DEBUG 6787 --- [nio-8090-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public 
2018-07-19 12:49:37.642  INFO 6787 --- [nio-8090-exec-1] c.a.a.f.m.rest.FakeController  : Incoming request with content null
2018-07-19 12:49:40.276  INFO 6787 --- [nio-8090-exec-1] c.a.a.f.m.rest.FakeController  : Stored Response with taskId 70555

这只是一个测试设置。我知道我没有使用任何数据。我在Spring Boot实现或设置中会错过什么吗?

0 个答案:

没有答案