Hi,
I'm writing a series of tests and wanted to remove a client filter,
however I'm getting the following exception:
com.sun.jersey.impl.client.urlconnection.URLConnectionClientHandler
cannot be cast to com.sun.jersey.api.client.filter.ClientFilter
java.lang.ClassCastException:
com.sun.jersey.impl.client.urlconnection.URLConnectionClientHandler
cannot be cast to com.sun.jersey.api.client.filter.ClientFilter
at
com.sun.jersey.api.client.filter.Filterable.removeFilter(Filterable.java:99)
I've been able to reproduce it using the following snippet of code,
although in the code that I first saw the behaviour in, I'm not using an
anonymous class or removing the filter immediately after adding it of
course ;-)
Client client = Client.create();
ClientFilter filter = new ClientFilter() {
@Override
public ClientResponse handle(ClientRequest cr)
throws ClientHandlerException {
return getNext().handle(cr);
}
};
client.addFilter(filter);
client.removeFilter(filter);
I'm using the version of Jersey that was installed through the Netbeans
6.5 plugin manager (v1.0.2). In my case, I've only got the one client
filter attached to the client so as a workaround I can just call
Client.removeAllFilters() but I'd be interested to know whether I'm
doing something wrong or whether I should log a defect?
Thanks,
Steve