Hi

I updated ConfigurableImpl to use LinledHashMap but you can not depend on the order of filters with the same default priority being preserved across multiple JAX-RS implementations, for example, in some cases the filters can be auto-discovered and as a such the order can not be guaranteed. JAX-RS ships Priorities constants class, and custom priority values can be defined. The existing filter sorting algorithm is not very robust and there's a request pending to make it more sophisticated but for now using priorities is the only way to ensure the right order is preserved

HTH, Sergey

On 05/09/14 05:47, jordan wrote:
Hi dear,

I'm using CXF client to access RS resource. And I register multiple
ClientResponseFilters for one client, but I see the execution order is
random, here is my code:

     public void testNew2ResponseFilter(Map<String, String> param,
StringBuilder ret) {
         String serverIP = param.get("serverIP");
         String serverPort = param.get("serverPort");

         ClientBuilder cb = ClientBuilder.newBuilder();
         Client c = cb.build();
*        c.register(ClientResponseFilter1.class);*
         WebTarget t1 = c.target("http://"; + serverIP + ":" + serverPort +
"/" + moduleName + "/ComplexClientTest/ComplexResource");
         *WebTarget t2 = c.target("http://"; + serverIP + ":" + serverPort +
"/" + moduleName +
"/ComplexClientTest/ComplexResource").register(ClientResponseFilter2.class);*
         Response res1 =
t1.path("echo1").path("test1").request().get(Response.class);
         Response res2 =
t2.path("echo2").path("test2").request().get(Response.class);
         System.out.println("config: " +
c.getConfiguration().getProperties());
         c.close();
         ret.append(res1.getStatus() + "," + res2.getStatus());
     }

I didn't set order number when I register the filters. So when I debug the
CXF code, I see if I didn't set order number for filter, CXF will set 5000
for ClientResponseFilter. And CXF will save filters to a provider list. But
this list is a HashMap (No order).... I'm not sure if can CXF change to
LinkedHashMap or other order list?

Here is the code in org.apache.cxf.jaxrs.impl.ConfigurationImpl:
private Map<Object, Map&lt;Class&lt;?>, Integer>> providers =
         new HashMap<Object, Map&lt;Class&lt;?>, Integer>>();

I'm not sure if I understand correct. If no, could you please correct me if
anything I write wrong to make the filter execution non-order.

Thanks a lot! :)



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Register-multiple-ClientResponseFilters-the-execution-order-is-random-because-the-providerlist-is-Ha-tp5748453.html
Sent from the cxf-dev mailing list archive at Nabble.com.


Reply via email to