Code example for HttpContext

Methods: getAttribute

0
    } 
 
    public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
        boolean retry = true;
 
        Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
        boolean sent = (b != null && b.booleanValue());
 
        if(executionCount > maxRetries) {
            retry = false;
        } else if (exceptionBlacklist.contains(exception.getClass())) {
        	// 黑名单 不在重连 
            retry = false;
        } else if (exceptionWhitelist.contains(exception.getClass())) {
        	 // 白名单需要重连 
            retry = true;
        } else if (!sent) {
        	// 还没完全发送 
            retry = true;
        } 
 
        if(retry) {
        	// 重新发送所有的idempotent请求 
            HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute( ExecutionContext.HTTP_REQUEST );
            String requestType = currentReq.getMethod();
            retry = !requestType.equals("POST");
        } 
 
        if(retry) {
Contextual code suggestions in your IDE  Get Codota for Java