brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [13/16] git commit: Treat empty strings as null values in shutdown request.
Date Fri, 19 Sep 2014 11:31:29 GMT
Treat empty strings as null values in shutdown request.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/4b7b9d66
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/4b7b9d66
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/4b7b9d66

Branch: refs/heads/master
Commit: 4b7b9d66f06ea86fb29978165cc083aa3196e5f6
Parents: 471ff27
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Fri Sep 19 13:08:17 2014 +0300
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Fri Sep 19 13:19:16 2014 +0300

----------------------------------------------------------------------
 .../java/brooklyn/rest/resources/ServerResource.java | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4b7b9d66/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java b/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
index 8de5c60..824b2ad 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/ServerResource.java
@@ -50,6 +50,7 @@ import brooklyn.rest.transform.HighAvailabilityTransformer;
 import brooklyn.rest.util.WebResourceUtils;
 import brooklyn.util.ResourceUtils;
 import brooklyn.util.exceptions.Exceptions;
+import brooklyn.util.text.Strings;
 import brooklyn.util.time.CountdownTimer;
 import brooklyn.util.time.Duration;
 import brooklyn.util.time.Time;
@@ -74,11 +75,11 @@ public class ServerResource extends AbstractBrooklynRestResource implements
Serv
             Long delayMillis) {
         log.info("REST call to shutdown server, stopAppsFirst="+stopAppsFirst+", delayForHttpReturn="+shutdownTimeoutRaw);
 
-        final Duration shutdownTimeout = Duration.parse(shutdownTimeoutRaw);
-        Duration requestTimeout = Duration.parse(requestTimeoutRaw);
+        final Duration shutdownTimeout = parseDuration(shutdownTimeoutRaw, Duration.of(20,
TimeUnit.SECONDS));
+        Duration requestTimeout = parseDuration(requestTimeoutRaw, Duration.of(20, TimeUnit.SECONDS));
         final Duration delayForHttpReturn;
         if (delayMillis == null) {
-            delayForHttpReturn = Duration.parse(delayForHttpReturnRaw);
+            delayForHttpReturn = parseDuration(delayForHttpReturnRaw, Duration.FIVE_SECONDS);
         } else {
             log.warn("'delayMillis' is deprecated, use 'delayForHttpReturn' instead.");
             delayForHttpReturn = Duration.of(delayMillis, TimeUnit.MILLISECONDS);
@@ -188,6 +189,14 @@ public class ServerResource extends AbstractBrooklynRestResource implements
Serv
         }
     }
 
+    private Duration parseDuration(String str, Duration defaultValue) {
+        if (Strings.isEmpty(str)) {
+            return defaultValue;
+        } else {
+            return Duration.parse(str);
+        }
+    }
+
     @Override
     public VersionSummary getVersion() {
         InputStream input = ResourceUtils.create().getResourceFromUrl("classpath://build-metadata.properties");


Mime
View raw message