Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62D3710D37 for ; Tue, 25 Feb 2014 14:45:43 +0000 (UTC) Received: (qmail 64712 invoked by uid 500); 25 Feb 2014 14:45:42 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 64685 invoked by uid 500); 25 Feb 2014 14:45:38 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 64668 invoked by uid 99); 25 Feb 2014 14:45:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Feb 2014 14:45:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Feb 2014 14:45:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7477A238896F for ; Tue, 25 Feb 2014 14:45:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1571714 - in /httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache: ExponentialBackOffSchedulingStrategy.java ImmediateSchedulingStrategy.java Date: Tue, 25 Feb 2014 14:45:15 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140225144515.7477A238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Tue Feb 25 14:45:14 2014 New Revision: 1571714 URL: http://svn.apache.org/r1571714 Log: Code cleanups Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java?rev=1571714&r1=1571713&r2=1571714&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java (original) +++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ExponentialBackOffSchedulingStrategy.java Tue Feb 25 14:45:14 2014 @@ -27,6 +27,7 @@ package org.apache.http.impl.client.cache; import org.apache.http.annotation.ThreadSafe; +import org.apache.http.util.Args; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -48,7 +49,8 @@ import java.util.concurrent.TimeUnit; * * The following equation is used to calculate the delay for a specific revalidation request: *
- *     delay = {@link #getInitialExpiryInMillis()} * Math.pow({@link #getBackOffRate()}, {@link AsynchronousValidationRequest#getConsecutiveFailedAttempts()} - 1))
+ *     delay = {@link #getInitialExpiryInMillis()} * Math.pow({@link #getBackOffRate()},
+ *     {@link AsynchronousValidationRequest#getConsecutiveFailedAttempts()} - 1))
  * 
* The resulting delay won't exceed {@link #getMaxExpiryInMillis()}. * @@ -117,16 +119,16 @@ public class ExponentialBackOffSchedulin final long backOffRate, final long initialExpiryInMillis, final long maxExpiryInMillis) { - this.executor = checkNotNull("executor", executor); - this.backOffRate = checkNotNegative("backOffRate", backOffRate); - this.initialExpiryInMillis = checkNotNegative("initialExpiryInMillis", initialExpiryInMillis); - this.maxExpiryInMillis = checkNotNegative("maxExpiryInMillis", maxExpiryInMillis); + this.executor = Args.notNull(executor, "Executor"); + this.backOffRate = Args.notNegative(backOffRate, "BackOffRate"); + this.initialExpiryInMillis = Args.notNegative(initialExpiryInMillis, "InitialExpiryInMillis"); + this.maxExpiryInMillis = Args.notNegative(maxExpiryInMillis, "MaxExpiryInMillis"); } @Override public void schedule( final AsynchronousValidationRequest revalidationRequest) { - checkNotNull("revalidationRequest", revalidationRequest); + Args.notNull(revalidationRequest, "RevalidationRequest"); final int consecutiveFailedAttempts = revalidationRequest.getConsecutiveFailedAttempts(); final long delayInMillis = calculateDelayInMillis(consecutiveFailedAttempts); executor.schedule(revalidationRequest, delayInMillis, TimeUnit.MILLISECONDS); @@ -160,6 +162,10 @@ public class ExponentialBackOffSchedulin } } + /** + * @deprecated Use {@link org.apache.http.util.Args#notNull(Object, String)} + */ + @Deprecated protected static T checkNotNull(final String parameterName, final T value) { if (value == null) { throw new IllegalArgumentException(parameterName + " may not be null"); @@ -167,6 +173,10 @@ public class ExponentialBackOffSchedulin return value; } + /** + * @deprecated Use {@link org.apache.http.util.Args#notNegative(long, String)} + */ + @Deprecated protected static long checkNotNegative(final String parameterName, final long value) { if (value < 0) { throw new IllegalArgumentException(parameterName + " may not be negative"); Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java?rev=1571714&r1=1571713&r2=1571714&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java (original) +++ httpcomponents/httpclient/trunk/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ImmediateSchedulingStrategy.java Tue Feb 25 14:45:14 2014 @@ -27,6 +27,7 @@ package org.apache.http.impl.client.cache; import org.apache.http.annotation.ThreadSafe; +import org.apache.http.util.Args; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ExecutorService; @@ -69,10 +70,7 @@ public class ImmediateSchedulingStrategy @Override public void schedule(final AsynchronousValidationRequest revalidationRequest) { - if (revalidationRequest == null) { - throw new IllegalArgumentException("AsynchronousValidationRequest may not be null"); - } - + Args.notNull(revalidationRequest, "AsynchronousValidationRequest"); executor.execute(revalidationRequest); }