Fix NullPointerExceptions in location config
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/e05fbb60 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/e05fbb60 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/e05fbb60 Branch: refs/heads/master Commit: e05fbb604fb8e1fba25c5e7d34a0b152b93159fb Parents: 8e1ad7e Author: Andrew Donald Kennedy <[email protected]> Authored: Tue Jan 31 15:23:09 2017 +0000 Committer: Andrew Donald Kennedy <[email protected]> Committed: Fri May 19 14:01:20 2017 +0100 ---------------------------------------------------------------------- .../amp/containerservice/kubernetes/entity/KubernetesPod.java | 3 --- .../containerservice/kubernetes/location/KubernetesLocation.java | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e05fbb60/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java ---------------------------------------------------------------------- diff --git a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java index e7858ba..6ac2b89 100644 --- a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java +++ b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/entity/KubernetesPod.java @@ -28,20 +28,17 @@ public interface KubernetesPod extends DockerContainer { ConfigKey<String> POD = ConfigKeys.builder(String.class) .name("pod") .description("The name of the pod") - .constraint(Predicates.<String>notNull()) .build(); @SuppressWarnings("serial") ConfigKey<List<String>> PERSISTENT_VOLUMES = ConfigKeys.builder(new TypeToken<List<String>>() {}) .name("persistentVolumes") .description("Persistent volumes used by the pod") - .constraint(Predicates.<List<String>>notNull()) .build(); ConfigKey<String> DEPLOYMENT = ConfigKeys.builder(String.class) .name("deployment") .description("The name of the service the deployed pod will use") - .constraint(Predicates.<String>notNull()) .build(); ConfigKey<Integer> REPLICAS = ConfigKeys.builder(Integer.class) http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e05fbb60/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocation.java ---------------------------------------------------------------------- diff --git a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocation.java b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocation.java index 03494bf..0b2c41f 100644 --- a/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocation.java +++ b/kubernetes-location/src/main/java/io/cloudsoft/amp/containerservice/kubernetes/location/KubernetesLocation.java @@ -49,6 +49,7 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Functions; import com.google.common.base.Joiner; +import com.google.common.base.MoreObjects; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.base.Predicates; @@ -976,7 +977,7 @@ public class KubernetesLocation extends AbstractLocation implements MachineProvi Optional<T> entityValue = Optional.fromNullable(entity.config().get(config)); Optional<T> locationValue = Optional.fromNullable(setup.get(config)); - return entityValue.or(locationValue).or(defaultValue); + return Iterables.getFirst(Optional.presentInstances(Arrays.asList(entityValue, locationValue)), defaultValue); } public void waitForExitCondition(ExitCondition exitCondition) {
