Jus*_*tin 5 tomcat jax-rs jersey jersey-client jersey-2.0
我们最近在服务器和客户端上从Jersey 1.x升级到Jersey 2.22.1.我们现在间歇地看到泽西岛将提出/接收两个请求.
我可以通过在此客户端POST请求上循环数千次来重现它.每个请求都会发送一个唯一的"名称",该名称将保留在服务器上.我知道当我遇到一个唯一的约束违规试图保持两次相同的"名称"时,我们收到了一个重复的请求.我排除了代码的其他部分,因为日志确认Jersey正在接收两个相同"名称"的POST请求
我已在服务器上的org.glassfish包中启用了跟踪日志记录,并在客户端上注册了LoggingFilter().
客户端仅显示1个POST请求和响应:
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8291 * Sending client request on thread main
8291 > POST http://localhost:9797/my-webapp/v1/data-feeds/
8291 > Accept: application/json
8291 > Content-Type: application/json
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8291 * Client response received on thread main
8291 < 200
8291 < Cache-Control: no-cache, no-store, max-age=0, must-revalidate
8291 < Content-Length: 181
8291 < Content-Type: application/json
8291 < Date: Wed, 22 Jun 2016 00:02:51 GMT
8291 < Expires: 0
8291 < Pragma: no-cache
8291 < Server: Apache-Coyote/1.1
8291 < Set-Cookie: JSESSIONID=CFF556E7FCDB5B1F644BA04603364DFD; Path=/my-webapp/; HttpOnly
8291 < X-Content-Type-Options: nosniff
8291 < X-Frame-Options: DENY
8291 < X-XSS-Protection: 1; mode=block
Run Code Online (Sandbox Code Playgroud)
服务器显示两个相同"名称"的POSTS:
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8293 * Server has received a request on thread http-bio-9797-exec-21
8293 > POST http://localhost:9797/my-webapp/v1/data-feeds/
8293 > accept: application/json
8293 > authorization: Basic YWRtaW46bmltZGE=
8293 > connection: keep-alive
8293 > content-length: 181
8293 > content-type: application/json
8293 > host: localhost:9797
8293 > user-agent: Jersey/2.22.1 (HttpUrlConnection 1.8.0_31)
2016-06-21 18:02:51,964 [INFO] [c.m.c.r.r.MyResource] Received POST request /data-feeds with args [FeedData{name='pool4146'}]
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8294 * Server has received a request on thread http-bio-9797-exec-97
8294 > POST http://localhost:9797/my-webapp/v1/data-feeds/
8294 > accept: application/json
8294 > authorization: Basic YWRtaW46bmltZGE=
8294 > connection: keep-alive
8294 > content-length: 181
8294 > content-type: application/json
8294 > host: localhost:9797
8294 > user-agent: Jersey/2.22.1 (HttpUrlConnection 1.8.0_31)
2016-06-21 18:02:51,978 [INFO] [c.m.c.r.r.MyResource] Received POST request /data-feeds with args [FeedData{name='pool4146'}]
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8293 * Server responded with a response on thread http-bio-9797-exec-21
8293 < 200
8293 < Content-Type: application/json
Jun 21, 2016 6:02:51 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 8294 * Server responded with a response on thread http-bio-9797-exec-97
8294 < 200
8294 < Content-Type: application/json
Run Code Online (Sandbox Code Playgroud)
如果此处有任何其他可能相关的配置信息,请告诉我.我们使用Tomcat 7.x和Jackson进行序列化/反序列化
小智 0
我遇到了同样的问题,并且无法复制这个问题。您是否尝试关闭 ClientResponse 流?让我知道结果如何。
Client client = new Client();
WebResource resource = client.resource(restUrl);
final ClientResponse response = resource.get(ClientResponse.class);
response.close();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1304 次 |
| 最近记录: |