hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yuchen Wang" <yw...@shopping.com>
Subject Bug in disabling retry of httpclient 3.0?
Date Tue, 20 Sep 2005 00:09:47 GMT
Hi,

I am using HttpClient 3.0 rc2 for our project. I try to disable the
retry when there is a failure with execution of an HTTP method. I
followed the instruction from
http://jakarta.apache.org/commons/httpclient/exception-handling.html#Cus
tom%20exception%20handler but it can NOT stop the httpclient from
retrying. 

 
httpclient.getHttpConnectionManager().getParams().setParameter(HttpMetho
dParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));

After looking at the source code of class HttpMethodDirector.java, I
found that the method executeWithRetry uses this code to get the
HttpMethodRetryHandler:

	handler =
(HttpMethodRetryHandler)method.getParams().getParameter(HttpMethodParams
.RETRY_HANDLER);

However, in the method of getParameter in class DefaultHttpParams.java,
this.parameters is always null even if I already set it, which caused
the problem. I have to use following code to disable the retry:

        PostMethod post = new
PostMethod("http://www.this_is_my_host.com");
        DefaultMethodRetryHandler handler = new
DefaultMethodRetryHandler();
        handler.setRetryCount(0);
        post.setMethodRetryHandler(handler);

Is this a bug? 

Also, in general, I don't think having the auto-retry turned as default
is a good idea. As a framework, tt should leave to the user to decide if
it needs to be turned on.

Thanks.

Yuchen


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message