阅读http://jersey.java.net/nonav/documentation/latest/client-api.html#d4e704处的文档让我觉得ClientFilter
按照添加顺序进行处理。然而,我看到了相反的情况。这是我正在测试的代码,类似于文档中显示的代码:
ClientFilter filter1 = new ClientFilter() {
@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
System.out.println("Modify Request 1");
ClientResponse response = getNext().handle(cr);
System.out.println("Modify Response 1");
return response;
}
};
ClientFilter filter2 = new ClientFilter() {
@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
System.out.println("Modify Request 2");
ClientResponse response = getNext().handle(cr);
System.out.println("Modify Response 2");
return response;
}
};
Client c = Client.create();
c.addFilter(filter1);
c.addFilter(filter2);
ClientFilter filter3 = new ClientFilter() {
@Override
public ClientResponse handle(ClientRequest cr) throws ClientHandlerException {
System.out.println("Modify Request 3");
ClientResponse response = getNext().handle(cr);
System.out.println("Modify Response 3");
return response;
}
};
WebResource r = c.resource("http://www.stackoverflow.com");
r.addFilter(filter3);
System.out.println(r.get(ClientResponse.class).getStatus());
我希望看到修改请求1 2 3,修改响应3 2 1,但我看到修改请求3 2 1修改响应1 2 3。
我只是向后解释文档吗?
答案 0 :(得分:0)
您可以在Jersey问题跟踪器上提交新问题吗? http://java.net/jira/browse/JERSEY/
谢谢!