You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by dj...@apache.org on 2014/05/10 07:58:17 UTC

svn commit: r1593668 - in /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent: ConcurrentUtils.java TimedSemaphore.java

Author: djones
Date: Sat May 10 05:58:17 2014
New Revision: 1593668

URL: http://svn.apache.org/r1593668
Log:
Using Validate where possible in concurrent package.

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java?rev=1593668&r1=1593667&r2=1593668&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java Sat May 10 05:58:17 2014
@@ -21,6 +21,8 @@ import java.util.concurrent.ExecutionExc
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>
  * An utility class providing functionality related to the {@code
@@ -141,12 +143,10 @@ public class ConcurrentUtils {
      * checked exception
      */
     static Throwable checkedException(final Throwable ex) {
-        if (ex != null && !(ex instanceof RuntimeException)
-                && !(ex instanceof Error)) {
-            return ex;
-        } else {
-            throw new IllegalArgumentException("Not a checked exception: " + ex);
-        }
+        Validate.isTrue(ex != null && !(ex instanceof RuntimeException)
+                && !(ex instanceof Error), "Not a checked exception: " + ex);
+        
+        return ex;
     }
 
     /**

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java?rev=1593668&r1=1593667&r2=1593668&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/concurrent/TimedSemaphore.java Sat May 10 05:58:17 2014
@@ -21,6 +21,8 @@ import java.util.concurrent.ScheduledFut
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.commons.lang3.Validate;
+
 /**
  * <p>
  * A specialized <em>semaphore</em> implementation that provides a number of
@@ -201,9 +203,7 @@ public class TimedSemaphore {
      */
     public TimedSemaphore(final ScheduledExecutorService service, final long timePeriod,
             final TimeUnit timeUnit, final int limit) {
-        if (timePeriod <= 0) {
-            throw new IllegalArgumentException("Time period must be greater 0!");
-        }
+        Validate.inclusiveBetween(1, Long.MAX_VALUE, timePeriod, "Time period must be greater than 0!");
 
         period = timePeriod;
         unit = timeUnit;