Discussion:
[Resteasy-users] problem setting connection timeout
Jeff Ramin
2015-03-20 19:40:04 UTC
Permalink
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!
--
Jeff Ramin
Software Engineer
Singlewire Software
2601 W Beltline Hwy #510
Madison, WI 53713

Phone Direct - 608.661.1172
www.singlewire.com
Ron Sigal
2015-04-26 00:53:50 UTC
Permalink
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
Post by Jeff Ramin
Hi folks.
Using resteasy 3.0.5, and I need to set connection and read timeouts on
a request.
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();
[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!
Jeff Ramin
2015-04-27 12:16:50 UTC
Permalink
Thanks Ron, but I worked around the problem (by using Resty instead of
resteasy), and
I don't have time to work on troubleshooting this problem.
Post by Ron Sigal
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
Post by Jeff Ramin
Hi folks.
Using resteasy 3.0.5, and I need to set connection and read timeouts on
a request.
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();
[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!
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Resteasy-users mailing list
https://lists.sourceforge.net/lists/listinfo/resteasy-users
--
Jeff Ramin
Software Engineer
Singlewire Software
2601 W Beltline Hwy #510
Madison, WI 53713

Phone Direct - 608.661.1172
www.singlewire.com
Ron Sigal
2015-04-27 17:10:24 UTC
Permalink
Ok, thanks, Jeff.
Post by Jeff Ramin
Thanks Ron, but I worked around the problem (by using Resty instead of
resteasy), and
I don't have time to work on troubleshooting this problem.
Post by Ron Sigal
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
Post by Jeff Ramin
Hi folks.
Using resteasy 3.0.5, and I need to set connection and read timeouts on
a request.
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();
[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!
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Resteasy-users mailing list
https://lists.sourceforge.net/lists/listinfo/resteasy-users
--
Jeff Ramin
Software Engineer
Singlewire Software
2601 W Beltline Hwy #510
Madison, WI 53713
Phone Direct - 608.661.1172
www.singlewire.com
Loading...