Improve timeout check error message 53/78453/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Dec 2018 10:26:34 +0000 (11:26 +0100)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 5 Dec 2018 15:15:17 +0000 (15:15 +0000)
Report the value being set in checkArgument.

Change-Id: I76e88504f794300634f61b293876e1677c549792
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/CommonConfig.java

index d57134d..6a350af 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.controller.cluster.common.actor;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import com.typesafe.config.Config;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class CommonConfig extends AbstractConfig {
@@ -83,7 +83,7 @@ public class CommonConfig extends AbstractConfig {
                 ? get().getDuration(PATH, TimeUnit.NANOSECONDS)
                 : DEFAULT_MAILBOX_PUSH_TIMEOUT;
 
-        cachedMailBoxPushTimeout = new FiniteDuration(timeout, TimeUnit.NANOSECONDS);
+        cachedMailBoxPushTimeout = FiniteDuration.create(timeout, TimeUnit.NANOSECONDS);
         return cachedMailBoxPushTimeout;
     }
 
@@ -107,7 +107,7 @@ public class CommonConfig extends AbstractConfig {
 
         @SuppressWarnings("unchecked")
         public T mailboxCapacity(int capacity) {
-            Preconditions.checkArgument(capacity > 0, "mailbox capacity must be >0");
+            checkArgument(capacity > 0, "mailbox capacity must be >0");
 
             Map<String, Object> boundedMailbox = (Map<String, Object>) configHolder.get(TAG_MAILBOX);
             boundedMailbox.put(TAG_MAILBOX_CAPACITY, capacity);
@@ -116,8 +116,8 @@ public class CommonConfig extends AbstractConfig {
 
         @SuppressWarnings("unchecked")
         public T mailboxPushTimeout(String timeout) {
-            Duration pushTimeout = Duration.create(timeout);
-            Preconditions.checkArgument(pushTimeout.isFinite(), "invalid value for mailbox push timeout");
+            checkArgument(FiniteDuration.create(timeout).isFinite(), "invalid value \"%s\" for mailbox push timeout",
+                timeout);
 
             Map<String, Object> boundedMailbox = (Map<String, Object>) configHolder.get(TAG_MAILBOX);
             boundedMailbox.put(TAG_MAILBOX_PUSH_TIMEOUT, timeout);

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.