Using Validate where possible in concurrent package.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1593668 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Duncan Jones 2014-05-10 05:58:17 +00:00
parent 10641f9ae7
commit a2c356d7a6
2 changed files with 9 additions and 9 deletions

View File

@ -21,6 +21,8 @@
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 static void handleCauseUnchecked(final ExecutionException ex) {
* 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;
}
/**

View File

@ -21,6 +21,8 @@
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 TimedSemaphore(final long timePeriod, final TimeUnit timeUnit, final int
*/
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;