From: Ron S. <rs...@re...> - 2015-04-26 00:54:01
|
Hey Jeff, I'm trying to duplicate your problem. I adapted your code in the attached TimeoutTest, but it runs fine. Could you fiddle with TimeoutTest and get it to throw the NPE? Thanks, Ron On 03/20/2015 03:40 PM, Jeff Ramin wrote: > Hi folks. > > Using resteasy 3.0.5, and I need to set connection and read timeouts on > a request. > Here's the code: > > org.apache.http.impl.client.DefaultHttpClient httpClient = new > org.apache.http.impl.client.DefaultHttpClient(); > HttpParams params = new org.apache.http.params.BasicHttpParams(); > > org.apache.http.params.HttpConnectionParams.setConnectionTimeout(params, > 4000); > org.apache.http.params.HttpConnectionParams.setSoTimeout(params, 2000); > httpClient.setParams(params); > > executor = new > org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor(httpClient); > > ClientRequest clientRequest = new ClientRequest(newPath, executor); > clientRequest = clientRequest.accept(getResponseMediaType()) > .body(getRequestMediaType(), request) > .followRedirects(false); > clientRequest = clientRequest.header("headerKey", "headerVal"); > T out = clientRequest.post(responseClassType).getEntity(); > > I'm seeing an NPE when this code is run: > > [java] java.lang.NullPointerException > [java] at > org.jboss.resteasy.spi.ResteasyProviderFactory.toHeaderString(ResteasyProviderFactory.java:1263) > [java] at > org.jboss.resteasy.client.ClientRequest.toHeaderString(ClientRequest.java:204) > [java] at > org.jboss.resteasy.client.ClientRequest.getHeaders(ClientRequest.java:329) > [java] at > org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:27) > [java] at > org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:47) > [java] at > org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:441) > [java] at > org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:682) > [java] at > org.jboss.resteasy.client.ClientRequest.post(ClientRequest.java:566) > [java] at > org.jboss.resteasy.client.ClientRequest.post(ClientRequest.java:571) > > > Any ideas on what I'm doing wrong? I get the error whether I include the > ClientRequest.header() call or not. > > Thanks! > > |