provisionr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From as...@apache.org
Subject [1/2] PROVISIONR-41. Fix Sonar violations (part 1)
Date Wed, 03 Jul 2013 14:56:50 GMT
Updated Branches:
  refs/heads/master 416958b5e -> e896d1ca2


http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CancelSpotRequests.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CancelSpotRequests.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CancelSpotRequests.java
index 6fdae06..e50d1d6 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CancelSpotRequests.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CancelSpotRequests.java
@@ -18,20 +18,17 @@
 
 package org.apache.provisionr.amazon.activities;
 
+import com.amazonaws.services.ec2.AmazonEC2;
+import com.amazonaws.services.ec2.model.CancelSpotInstanceRequestsRequest;
 import static com.google.common.base.Preconditions.checkNotNull;
-
 import java.util.List;
-
 import org.activiti.engine.delegate.DelegateExecution;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.amazonaws.services.ec2.AmazonEC2;
-import com.amazonaws.services.ec2.model.CancelSpotInstanceRequestsRequest;
 import org.apache.provisionr.amazon.AmazonProvisionr;
 import org.apache.provisionr.amazon.ProcessVariables;
 import org.apache.provisionr.amazon.core.ProviderClientCache;
 import org.apache.provisionr.api.pool.Pool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class CancelSpotRequests extends AmazonActivity {
 
@@ -42,13 +39,13 @@ public class CancelSpotRequests extends AmazonActivity {
     }
 
     @Override
-    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception {
+    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) {
         @SuppressWarnings("unchecked")
         List<String> requests = (List<String>) execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS);
         checkNotNull(requests, "process variable '{}' not found", ProcessVariables.SPOT_INSTANCE_REQUEST_IDS);
         if (requests.size() > 0) {
             client.cancelSpotInstanceRequests(new CancelSpotInstanceRequestsRequest()
-                    .withSpotInstanceRequestIds(requests));
+                .withSpotInstanceRequestIds(requests));
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CheckAllRequestsAreActive.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CheckAllRequestsAreActive.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CheckAllRequestsAreActive.java
index 5f9a9b4..c326cca 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CheckAllRequestsAreActive.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/CheckAllRequestsAreActive.java
@@ -46,7 +46,7 @@ public class CheckAllRequestsAreActive extends AllSpotRequestsMatchPredicate {
     }
 
     @Override
-    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception {
+    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) {
         super.execute(client, pool, execution);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/DumpConsoleOutput.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/DumpConsoleOutput.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/DumpConsoleOutput.java
index 4f709c5..204c52a 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/DumpConsoleOutput.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/DumpConsoleOutput.java
@@ -21,13 +21,14 @@ package org.apache.provisionr.amazon.activities;
 import com.amazonaws.services.ec2.AmazonEC2;
 import com.amazonaws.services.ec2.model.GetConsoleOutputRequest;
 import com.amazonaws.services.ec2.model.GetConsoleOutputResult;
-import org.apache.provisionr.amazon.core.ProviderClientCache;
-import org.apache.provisionr.api.pool.Machine;
-import org.apache.provisionr.api.pool.Pool;
 import com.google.common.base.Charsets;
 import static com.google.common.base.Preconditions.checkNotNull;
+import java.io.IOException;
 import net.schmizz.sshj.common.Base64;
 import org.activiti.engine.delegate.DelegateExecution;
+import org.apache.provisionr.amazon.core.ProviderClientCache;
+import org.apache.provisionr.api.pool.Machine;
+import org.apache.provisionr.api.pool.Pool;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -40,7 +41,7 @@ public class DumpConsoleOutput extends AmazonActivity {
     }
 
     @Override
-    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception {
+    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws IOException {
         Machine machine = (Machine) execution.getVariable("machine");
         checkNotNull(machine, "expecting 'machine' as a process variable");
 

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/GetInstanceIdsFromSpotRequests.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/GetInstanceIdsFromSpotRequests.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/GetInstanceIdsFromSpotRequests.java
index 4639b77..d8cc83c 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/GetInstanceIdsFromSpotRequests.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/GetInstanceIdsFromSpotRequests.java
@@ -40,7 +40,7 @@ public class GetInstanceIdsFromSpotRequests extends AmazonActivity {
     }
 
     @Override
-    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception {
+    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) {
         LOG.info(">> retrieving instance Ids from spot request Ids");
 
         @SuppressWarnings("unchecked")
@@ -48,12 +48,14 @@ public class GetInstanceIdsFromSpotRequests extends AmazonActivity {
             (List<String>) execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS);
         DescribeSpotInstanceRequestsResult result = client.describeSpotInstanceRequests(
             new DescribeSpotInstanceRequestsRequest().withSpotInstanceRequestIds(requestIds));
+
         List<String> instanceIds = new ArrayList<String>();
         for (SpotInstanceRequest spotRequest : result.getSpotInstanceRequests()) {
             if (spotRequest.getInstanceId() != null) {
                 instanceIds.add(spotRequest.getInstanceId());
             }
         }
+
         execution.setVariable(ProcessVariables.INSTANCE_IDS, instanceIds);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/PublishListOfMachines.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/PublishListOfMachines.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/PublishListOfMachines.java
index f1723be..13841c2 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/PublishListOfMachines.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/PublishListOfMachines.java
@@ -50,7 +50,7 @@ public class PublishListOfMachines extends AmazonActivity {
     }
 
     @Override
-    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception {
+    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) {
         @SuppressWarnings("unchecked")
         List<String> instanceIds = (List<String>) execution.getVariable(ProcessVariables.INSTANCE_IDS);
         checkNotNull(instanceIds, "%s not found as a process variable", ProcessVariables.INSTANCE_IDS);

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/RunSpotInstances.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/RunSpotInstances.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/RunSpotInstances.java
index a798c73..8ddf3c9 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/RunSpotInstances.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/RunSpotInstances.java
@@ -30,6 +30,7 @@ import com.google.common.base.Optional;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.Uninterruptibles;
+import java.io.IOException;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 import org.activiti.engine.delegate.DelegateExecution;
@@ -43,34 +44,35 @@ import org.slf4j.LoggerFactory;
 public class RunSpotInstances extends RunInstances {
 
     private static final Logger LOG = LoggerFactory.getLogger(RunSpotInstances.class);
-    
+
     public RunSpotInstances(ProviderClientCache cache) {
         super(cache);
     }
 
     @Override
-    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception {
+    public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws IOException {
         /* before sending a new request, we check to see if we already registered
            a launch group with the process ID, if yes, we don't re-send the request */
         final String businessKey = execution.getProcessBusinessKey();
 
         /* we timeout if requests have already been sent - the activity is being retried. */
         Optional<Object> alreadySent = Optional.fromNullable(
-                execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS));
+            execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS));
 
         if (alreadySent.isPresent()) {
             DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpotInstanceRequestsRequest()
-                    .withFilters(new Filter()
-                        .withName("launch-group").withValues(businessKey)
-                        .withName("state").withValues("open", "active"));
+                .withFilters(new Filter()
+                    .withName("launch-group").withValues(businessKey)
+                    .withName("state").withValues("open", "active"));
+
             Stopwatch stopwatch = new Stopwatch().start();
             while (stopwatch.elapsedTime(TimeUnit.MINUTES) < 2) {
                 DescribeSpotInstanceRequestsResult result = client.describeSpotInstanceRequests(describeRequest);
                 List<SpotInstanceRequest> pending = result.getSpotInstanceRequests();
                 if (pending.size() > 0) {
                     LOG.info("Not resending spot instance requests {} for businessKey: {}.", pending, businessKey);
-                    execution.setVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS, 
-                            collectSpotInstanceRequestIds(pending));
+                    execution.setVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS,
+                        collectSpotInstanceRequestIds(pending));
                     return;
                 }
                 LOG.info("The describe call has not returned anything yet, waiting 20s and retrying.");
@@ -85,7 +87,7 @@ public class RunSpotInstances extends RunInstances {
 
         execution.setVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS, spotInstanceRequestIds);
     }
-    
+
     private List<String> collectSpotInstanceRequestIds(List<SpotInstanceRequest> requestResponses) {
         /* Make a copy as an ArrayList to force lazy collection evaluation */
         return Lists.newArrayList(Lists.transform(requestResponses,

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/SetupAdminAccess.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/SetupAdminAccess.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/SetupAdminAccess.java
index 26db218..bae3dd5 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/SetupAdminAccess.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/SetupAdminAccess.java
@@ -19,6 +19,7 @@
 package org.apache.provisionr.amazon.activities;
 
 import com.google.common.base.Charsets;
+import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.io.Resources;
 import java.io.IOException;
@@ -47,12 +48,17 @@ public class SetupAdminAccess extends PuppetActivity {
     }
 
     @Override
-    public String createPuppetScript(Pool pool, Machine machine) throws Exception {
-        return Mustache.toString(getClass(), ADMIN_ACCESS_TEMPLATE,
-            ImmutableMap.of(
-                "user", pool.getAdminAccess().getUsername(),
-                "publicKey", getRawSshKey(pool))
-        );
+    public String createPuppetScript(Pool pool, Machine machine) {
+        try {
+            return Mustache.toString(getClass(), ADMIN_ACCESS_TEMPLATE,
+                ImmutableMap.of(
+                    "user", pool.getAdminAccess().getUsername(),
+                    "publicKey", getRawSshKey(pool))
+            );
+
+        } catch (IOException e) {
+            throw Throwables.propagate(e);
+        }
     }
 
     private String getRawSshKey(Pool pool) {
@@ -60,14 +66,19 @@ public class SetupAdminAccess extends PuppetActivity {
     }
 
     @Override
-    public Map<String, String> createAdditionalFiles(Pool pool, Machine machine) throws IOException {
-        return ImmutableMap.of(
-            "/tmp/sshd_config",
-            Mustache.toString(getClass(), SSHD_CONFIG_TEMPLATE,
-                ImmutableMap.of("user", pool.getAdminAccess().getUsername())),
-            "/tmp/sudoers",
-            Resources.toString(Resources.getResource(getClass(), SUDOERS_TEMPLATE), Charsets.UTF_8)
-        );
+    public Map<String, String> createAdditionalFiles(Pool pool, Machine machine) {
+        try {
+            return ImmutableMap.of(
+                "/tmp/sshd_config",
+                Mustache.toString(getClass(), SSHD_CONFIG_TEMPLATE,
+                    ImmutableMap.of("user", pool.getAdminAccess().getUsername())),
+                "/tmp/sudoers",
+                Resources.toString(Resources.getResource(getClass(), SUDOERS_TEMPLATE), Charsets.UTF_8)
+            );
+
+        } catch (IOException e) {
+            throw Throwables.propagate(e);
+        }
 
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/TerminateInstances.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/TerminateInstances.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/TerminateInstances.java
index ca90347..89a6b71 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/TerminateInstances.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/activities/TerminateInstances.java
@@ -18,18 +18,14 @@
 
 package org.apache.provisionr.amazon.activities;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 import com.amazonaws.services.ec2.AmazonEC2;
 import com.amazonaws.services.ec2.model.TerminateInstancesRequest;
-import org.apache.provisionr.amazon.ProcessVariables;
-import org.apache.provisionr.amazon.core.ProviderClientCache;
-import org.apache.provisionr.api.pool.Pool;
 import com.google.common.base.Optional;
-
 import java.util.List;
-
 import org.activiti.engine.delegate.DelegateExecution;
+import org.apache.provisionr.amazon.ProcessVariables;
+import org.apache.provisionr.amazon.core.ProviderClientCache;
+import org.apache.provisionr.api.pool.Pool;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,8 +43,8 @@ public class TerminateInstances extends AmazonActivity {
     @Override
     public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) {
         @SuppressWarnings("unchecked")
-        Optional<List<String>> instanceIds = 
-                Optional.fromNullable((List<String>) execution.getVariable(ProcessVariables.INSTANCE_IDS));
+        Optional<List<String>> instanceIds =
+            Optional.fromNullable((List<String>) execution.getVariable(ProcessVariables.INSTANCE_IDS));
 
         LOG.info(">> Terminating instances: {}", instanceIds);
         if (instanceIds.isPresent() && instanceIds.get().size() > 0) {

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ErrorCodes.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ErrorCodes.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ErrorCodes.java
index 75f2734..edd8fe1 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ErrorCodes.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ErrorCodes.java
@@ -18,7 +18,7 @@
 
 package org.apache.provisionr.amazon.core;
 
-public class ErrorCodes {
+public final class ErrorCodes {
 
     private ErrorCodes() {
         /* singleton */

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ImageTable.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ImageTable.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ImageTable.java
index afcf101..c3f6b25 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ImageTable.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ImageTable.java
@@ -81,6 +81,7 @@ public class ImageTable {
             new Function<Map.Entry<String, String>, Table.Cell<String, String, String>>() {
                 @Override
                 public Table.Cell<String, String, String> apply(Map.Entry<String, String> entry) {
+                    checkNotNull(entry, "entry is null");
                     return Tables.immutableCell(rowKey, entry.getKey(), entry.getValue());
                 }
             });

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/KeyPairs.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/KeyPairs.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/KeyPairs.java
index 50fc7ea..b391cd5 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/KeyPairs.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/KeyPairs.java
@@ -18,7 +18,7 @@
 
 package org.apache.provisionr.amazon.core;
 
-public class KeyPairs {
+public final class KeyPairs {
 
     private KeyPairs() {
         /* singleton */

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ProviderClientCacheSupplier.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ProviderClientCacheSupplier.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ProviderClientCacheSupplier.java
index 101be25..08c0440 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ProviderClientCacheSupplier.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/ProviderClientCacheSupplier.java
@@ -53,7 +53,7 @@ public class ProviderClientCacheSupplier implements Supplier<ProviderClientCache
     private static class ProviderClientCacheLoader extends CacheLoader<Provider, AmazonEC2> {
 
         @Override
-        public AmazonEC2 load(Provider provider) throws Exception {
+        public AmazonEC2 load(Provider provider) {
             String region = Optional.fromNullable(provider.getOptions().get(ProviderOptions.REGION))
                 .or(ProviderOptions.DEFAULT_REGION);
 

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/SecurityGroups.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/SecurityGroups.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/SecurityGroups.java
index 01d0e0e..9cb2cd7 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/SecurityGroups.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/core/SecurityGroups.java
@@ -18,7 +18,7 @@
 
 package org.apache.provisionr.amazon.core;
 
-public class SecurityGroups {
+public final class SecurityGroups {
 
     private SecurityGroups() {
         /* singleton */

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertIpPermissionToRule.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertIpPermissionToRule.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertIpPermissionToRule.java
index 973808f..9558dba 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertIpPermissionToRule.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertIpPermissionToRule.java
@@ -19,17 +19,20 @@
 package org.apache.provisionr.amazon.functions;
 
 import com.amazonaws.services.ec2.model.IpPermission;
+import com.google.common.base.Function;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.getOnlyElement;
 import org.apache.provisionr.api.network.Protocol;
 import org.apache.provisionr.api.network.Rule;
 import org.apache.provisionr.api.network.RuleBuilder;
-import com.google.common.base.Function;
-import static com.google.common.collect.Iterables.getOnlyElement;
 
 public enum ConvertIpPermissionToRule implements Function<IpPermission, Rule> {
     FUNCTION;
 
     @Override
     public Rule apply(IpPermission ipPermission) {
+        checkNotNull(ipPermission, "ipPermission is null");
+
         final RuleBuilder builder = Rule.builder().cidr(getOnlyElement(ipPermission.getIpRanges()))
             .protocol(Protocol.valueOf(ipPermission.getIpProtocol().toUpperCase()));
 

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertRuleToIpPermission.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertRuleToIpPermission.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertRuleToIpPermission.java
index ea372c8..b4d9c52 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertRuleToIpPermission.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/functions/ConvertRuleToIpPermission.java
@@ -19,14 +19,17 @@
 package org.apache.provisionr.amazon.functions;
 
 import com.amazonaws.services.ec2.model.IpPermission;
-import org.apache.provisionr.api.network.Rule;
 import com.google.common.base.Function;
+import static com.google.common.base.Preconditions.checkNotNull;
+import org.apache.provisionr.api.network.Rule;
 
 public enum ConvertRuleToIpPermission implements Function<Rule, IpPermission> {
     FUNCTION;
 
     @Override
     public IpPermission apply(Rule rule) {
+        checkNotNull(rule, "rule is null");
+
         IpPermission permission = new IpPermission()
             .withIpProtocol(rule.getProtocol().toString().toLowerCase())
             .withIpRanges(rule.getCidr());

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/ProviderOptions.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/ProviderOptions.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/ProviderOptions.java
index 3a1868e..71d2089 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/ProviderOptions.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/ProviderOptions.java
@@ -18,7 +18,7 @@
 
 package org.apache.provisionr.amazon.options;
 
-public class ProviderOptions {
+public final class ProviderOptions {
 
     private ProviderOptions() {
         /* singleton */

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/SoftwareOptions.java
----------------------------------------------------------------------
diff --git a/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/SoftwareOptions.java b/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/SoftwareOptions.java
index 2e29ebb..2c8a062 100644
--- a/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/SoftwareOptions.java
+++ b/providers/amazon/src/main/java/org/apache/provisionr/amazon/options/SoftwareOptions.java
@@ -18,7 +18,7 @@
 
 package org.apache.provisionr.amazon.options;
 
-public class SoftwareOptions {
+public final class SoftwareOptions {
 
     private SoftwareOptions() {
         /* singleton */

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/NetworkOptions.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/NetworkOptions.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/NetworkOptions.java
index edfc9d5..a480fa3 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/NetworkOptions.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/NetworkOptions.java
@@ -22,10 +22,9 @@ package org.apache.provisionr.cloudstack;
  * {@link org.apache.provisionr.api.network.Network Network} configuration is passed via the
  * {@link org.apache.provisionr.api.pool.Pool Pool} object. This class stores names for those options.
  */
-public class NetworkOptions {
+public final class NetworkOptions {
 
     private NetworkOptions() {
-        throw new RuntimeException("Do not instantiate");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/ProviderOptions.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/ProviderOptions.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/ProviderOptions.java
index 5002c56..9979c1a 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/ProviderOptions.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/ProviderOptions.java
@@ -21,19 +21,20 @@ package org.apache.provisionr.cloudstack;
 
 /**
  * Building a pool of VM's on CloudStack requires more knowledge of the cloud's architecture,
- * You need to know things like in what zone to build the pool, the ID's of service offerings, network offerings,
- * and more.
+ * <p/>
+ * You need to know things like in what zone to build the pool, the ID's of service
+ * offerings, network offerings, and more.
  * <p/>
  * All the information is passed via Provider Options. This class stores some of the option names.
  */
-public class ProviderOptions {
+public final class ProviderOptions {
 
     private ProviderOptions() {
-        throw new RuntimeException(ProviderOptions.class.getName() + " should not be instantiated");
     }
 
     public static final String ZONE_ID = "zoneId";
     public static final String TEMPLATE_ID = "templateId";
+
     public static final String SERVICE_OFFERING_ID = "serviceOfferingId";
     public static final String NETWORK_OFFERING_ID = "networkOfferingId";
 }

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/CloudStackActivity.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/CloudStackActivity.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/CloudStackActivity.java
index 82c3d38..322d5b4 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/CloudStackActivity.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/CloudStackActivity.java
@@ -36,16 +36,12 @@ import org.jclouds.cloudstack.CloudStackAsyncClient;
 import org.jclouds.cloudstack.CloudStackClient;
 import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
 import org.jclouds.rest.RestContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Base class for all activities that require access to a CloudStack based cloud.
  */
 public abstract class CloudStackActivity implements JavaDelegate {
 
-    private static final Logger LOG = LoggerFactory.getLogger(CloudStackActivity.class);
-
     /**
      * Implement activity logic in this method. It will be called with a reference to the {@link CloudStackClient}
      */
@@ -72,8 +68,10 @@ public abstract class CloudStackActivity implements JavaDelegate {
      */
     RestContext<CloudStackClient, CloudStackAsyncClient> newCloudStackClient(Provider provider) {
         checkArgument(provider.getEndpoint().isPresent(), "please specify an endpoint for this provider");
+
         Properties overrides = new Properties();
         overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
+
         return ContextBuilder.newBuilder(new CloudStackApiMetadata())
             .endpoint(provider.getEndpoint().get())
             .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule()))

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/DeleteSecurityGroup.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/DeleteSecurityGroup.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/DeleteSecurityGroup.java
index a99c79c..68458dc 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/DeleteSecurityGroup.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/DeleteSecurityGroup.java
@@ -18,17 +18,13 @@
 
 package org.apache.provisionr.cloudstack.activities;
 
+import org.activiti.engine.delegate.DelegateExecution;
 import org.apache.provisionr.api.pool.Pool;
 import org.apache.provisionr.cloudstack.core.SecurityGroups;
-import org.activiti.engine.delegate.DelegateExecution;
 import org.jclouds.cloudstack.CloudStackClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class DeleteSecurityGroup extends CloudStackActivity {
 
-    private static final Logger LOG = LoggerFactory.getLogger(DeleteSecurityGroup.class);
-
     @Override
     public void execute(CloudStackClient cloudStackClient, Pool pool, DelegateExecution execution) {
         String securityGroupName = SecurityGroups.formatNameFromBusinessKey(execution.getProcessBusinessKey());

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/RunInstances.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/RunInstances.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/RunInstances.java
index f82a907..91fff92 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/RunInstances.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/activities/RunInstances.java
@@ -18,14 +18,13 @@
 
 package org.apache.provisionr.cloudstack.activities;
 
+import org.activiti.engine.delegate.DelegateExecution;
 import org.apache.provisionr.api.pool.Pool;
 import org.apache.provisionr.cloudstack.ProviderOptions;
 import org.apache.provisionr.cloudstack.core.KeyPairs;
 import org.apache.provisionr.cloudstack.core.Networks;
 import org.apache.provisionr.cloudstack.core.VirtualMachines;
-import org.activiti.engine.delegate.DelegateExecution;
 import org.jclouds.cloudstack.CloudStackClient;
-import org.jclouds.cloudstack.domain.AsyncCreateResponse;
 import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,14 +45,14 @@ public class RunInstances extends CloudStackActivity {
 
         LOG.info("Starting instances!");
 
-        AsyncCreateResponse asyncCreateResponse = cloudStackClient.getVirtualMachineClient()
-            .deployVirtualMachineInZone(zoneId, serviceOffering, templateId,
-                DeployVirtualMachineOptions.Builder
-                    .displayName(businessKey)
-                    .group(businessKey)
-                    .networkId(Networks.formatNameFromBusinessKey(businessKey))
-                    .keyPair(keyPairName)
-                    .name(businessKey));
+        cloudStackClient.getVirtualMachineClient().deployVirtualMachineInZone(
+            zoneId, serviceOffering, templateId,
+            DeployVirtualMachineOptions.Builder
+                .displayName(businessKey)
+                .group(businessKey)
+                .networkId(Networks.formatNameFromBusinessKey(businessKey))
+                .keyPair(keyPairName)
+                .name(businessKey));
 
         VirtualMachines.waitForVMtoStart(cloudStackClient, businessKey);
     }

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java
index 204618b..644aa9f 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/CommandSupport.java
@@ -18,13 +18,13 @@
 
 package org.apache.provisionr.cloudstack.commands;
 
-import org.apache.provisionr.api.provider.Provider;
-import org.apache.provisionr.cloudstack.DefaultProviderConfig;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.io.Closeables;
 import java.io.PrintStream;
 import java.util.Properties;
 import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.provisionr.api.provider.Provider;
+import org.apache.provisionr.cloudstack.DefaultProviderConfig;
 import org.jclouds.Constants;
 import org.jclouds.ContextBuilder;
 import org.jclouds.cloudstack.CloudStackApiMetadata;
@@ -40,7 +40,6 @@ import org.jclouds.rest.RestContext;
  */
 public abstract class CommandSupport extends OsgiCommandSupport {
 
-    private RestContext<CloudStackClient, CloudStackAsyncClient> context = null;
     public static final String CLOUDSTACK_SCOPE = "cloudstack";
 
     private final Provider provider;
@@ -53,9 +52,11 @@ public abstract class CommandSupport extends OsgiCommandSupport {
 
     @Override
     protected Object doExecute() throws Exception {
+        RestContext<CloudStackClient, CloudStackAsyncClient> context = null;
         try {
             context = newCloudStackContext(provider);
             return doExecuteWithContext(context.getApi(), System.out);
+
         } finally {
             Closeables.closeQuietly(context);
         }

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java
index 0445002..87200a8 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/OfferingsCommand.java
@@ -18,10 +18,10 @@
 
 package org.apache.provisionr.cloudstack.commands;
 
-import org.apache.provisionr.cloudstack.DefaultProviderConfig;
 import java.io.PrintStream;
 import org.apache.felix.gogo.commands.Command;
 import org.apache.felix.gogo.commands.Option;
+import org.apache.provisionr.cloudstack.DefaultProviderConfig;
 import org.jclouds.cloudstack.CloudStackClient;
 import org.jclouds.cloudstack.domain.DiskOffering;
 import org.jclouds.cloudstack.domain.NetworkOffering;
@@ -47,9 +47,10 @@ public class OfferingsCommand extends CommandSupport {
     }
 
     @Override
-    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception {
+    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) {
         if (isDiskOfferingListed() || isServiceOfferingListed() || isNetworkOfferingListed()) {
             out.printf("CloudStack Offerings for provider %s\n", getProvider().getId());
+
             listServiceOfferingsIfSpecified(client, out);
             listNetworkOfferingsIfSpecified(client, out);
             listDiskOfferingsIfSpecified(client, out);

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java
index 9568700..e33d47b 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/TemplatesCommand.java
@@ -18,9 +18,9 @@
 
 package org.apache.provisionr.cloudstack.commands;
 
-import org.apache.provisionr.cloudstack.DefaultProviderConfig;
 import java.io.PrintStream;
 import org.apache.felix.gogo.commands.Command;
+import org.apache.provisionr.cloudstack.DefaultProviderConfig;
 import org.jclouds.cloudstack.CloudStackClient;
 import org.jclouds.cloudstack.domain.Template;
 
@@ -35,11 +35,11 @@ public class TemplatesCommand extends CommandSupport {
     }
 
     @Override
-    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception {
+    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) {
         out.printf("CloudStack templates for provider %s\n", getProvider().getId());
 
         for (Template template : client.getTemplateClient().listTemplates()) {
-            out.printf("---\n%s\n", template.toString());
+            out.printf("---%n%s%n", template.toString());
         }
         out.println();
         return null;

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java
index b078216..8c31481 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/commands/ZonesCommand.java
@@ -18,9 +18,9 @@
 
 package org.apache.provisionr.cloudstack.commands;
 
-import org.apache.provisionr.cloudstack.DefaultProviderConfig;
 import java.io.PrintStream;
 import org.apache.felix.gogo.commands.Command;
+import org.apache.provisionr.cloudstack.DefaultProviderConfig;
 import org.jclouds.cloudstack.CloudStackClient;
 import org.jclouds.cloudstack.domain.Zone;
 
@@ -35,10 +35,10 @@ public class ZonesCommand extends CommandSupport {
     }
 
     @Override
-    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) throws Exception {
-        out.printf("CloudStack zones for provider %s\n", getProvider().getId());
+    public Object doExecuteWithContext(CloudStackClient client, PrintStream out) {
+        out.printf("CloudStack zones for provider %s%n", getProvider().getId());
         for (Zone zone : client.getZoneClient().listZones()) {
-            out.printf("---\n%s\n", zone.toString());
+            out.printf("---%n%s%n", zone.toString());
         }
         out.println();
         return null;

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java
index b7fad3f..cb8ab1d 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/ConvertIngressRuleToRule.java
@@ -18,29 +18,32 @@
 
 package org.apache.provisionr.cloudstack.core;
 
+import com.google.common.base.Function;
+import static com.google.common.base.Preconditions.checkNotNull;
 import org.apache.provisionr.api.network.Protocol;
 import org.apache.provisionr.api.network.Rule;
-import com.google.common.base.Function;
 import org.jclouds.cloudstack.domain.IngressRule;
 
 public enum ConvertIngressRuleToRule implements Function<IngressRule, Rule> {
     FUNCTION;
 
     @Override
-    public Rule apply(IngressRule input) {
+    public Rule apply(IngressRule ingressRule) {
+        checkNotNull(ingressRule, "ingressRule is null");
+
         Rule rule;
-        if (input.getProtocol().equalsIgnoreCase("icmp")) {
+        if (ingressRule.getProtocol().equalsIgnoreCase("icmp")) {
             rule = Rule.builder()
                 .anySource()
-                .protocol(Protocol.valueOf(input.getProtocol().toUpperCase()))
-                .cidr(input.getCIDR())
+                .protocol(Protocol.valueOf(ingressRule.getProtocol().toUpperCase()))
+                .cidr(ingressRule.getCIDR())
                 .createRule();
         } else {
             rule = Rule.builder()
                 .anySource()
-                .protocol(Protocol.valueOf(input.getProtocol().toUpperCase()))
-                .ports(input.getStartPort(), input.getEndPort())
-                .cidr(input.getCIDR())
+                .protocol(Protocol.valueOf(ingressRule.getProtocol().toUpperCase()))
+                .ports(ingressRule.getStartPort(), ingressRule.getEndPort())
+                .cidr(ingressRule.getCIDR())
                 .createRule();
         }
         return rule;

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java
index f3745db..403adbf 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/KeyPairs.java
@@ -18,7 +18,7 @@
 
 package org.apache.provisionr.cloudstack.core;
 
-public class KeyPairs {
+public final class KeyPairs {
 
     private KeyPairs() {
         // singleton

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java
index 8d31b8f..ea4587a 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Networks.java
@@ -26,7 +26,7 @@ import java.util.Set;
 import org.jclouds.cloudstack.CloudStackClient;
 import org.jclouds.cloudstack.domain.Network;
 
-public class Networks {
+public final class Networks {
 
     private Networks() {
     }
@@ -42,12 +42,14 @@ public class Networks {
      * @throws IllegalArgumentException if more networks with the same name are found
      */
     public static Network getByName(CloudStackClient client, final String networkName) {
-        Set<Network> networks = Sets.filter(client.getNetworkClient().listNetworks(), new Predicate<Network>() {
-            @Override
-            public boolean apply(Network input) {
-                return input.getName().equals(networkName);
-            }
-        });
+        Set<Network> networks = Sets.filter(client.getNetworkClient().listNetworks(),
+            new Predicate<Network>() {
+                @Override
+                public boolean apply(Network network) {
+                    return network != null && network.getName().equals(networkName);
+                }
+            });
+
         return Iterables.getOnlyElement(networks);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java
index 6acaa3c..cd41591 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/SecurityGroups.java
@@ -18,14 +18,14 @@
 
 package org.apache.provisionr.cloudstack.core;
 
-import org.apache.provisionr.api.network.Network;
-import org.apache.provisionr.api.network.Protocol;
-import org.apache.provisionr.api.network.Rule;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import java.util.NoSuchElementException;
 import java.util.Set;
+import org.apache.provisionr.api.network.Network;
+import org.apache.provisionr.api.network.Protocol;
+import org.apache.provisionr.api.network.Rule;
 import org.jclouds.cloudstack.CloudStackClient;
 import org.jclouds.cloudstack.domain.IngressRule;
 import org.jclouds.cloudstack.domain.SecurityGroup;
@@ -34,7 +34,7 @@ import static org.jclouds.cloudstack.options.ListSecurityGroupsOptions.Builder.n
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SecurityGroups {
+public final class SecurityGroups {
 
     private static final Logger LOG = LoggerFactory.getLogger(SecurityGroup.class);
     public static final int DEFAULT_ICMP_CODE = 0;

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java
index 4211d4e..e31ca68 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/VirtualMachines.java
@@ -51,7 +51,7 @@ public class VirtualMachines {
             .listVirtualMachines(ListVirtualMachinesOptions.Builder.name(vmName)), new Predicate<VirtualMachine>() {
             @Override
             public boolean apply(VirtualMachine input) {
-                return vmName.equals(input.getDisplayName());
+                return input != null && vmName.equals(input.getDisplayName());
             }
         });
 
@@ -101,7 +101,7 @@ public class VirtualMachines {
             .listVirtualMachines(ListVirtualMachinesOptions.Builder.name(vmName)), new Predicate<VirtualMachine>() {
             @Override
             public boolean apply(VirtualMachine input) {
-                return vmName.equals(input.getDisplayName());
+                return input != null && vmName.equals(input.getDisplayName());
             }
         });
         return Iterables.getOnlyElement(machines);

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java
----------------------------------------------------------------------
diff --git a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java
index 069b9d8..bc93071 100644
--- a/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java
+++ b/providers/cloudstack/src/main/java/org/apache/provisionr/cloudstack/core/Zones.java
@@ -25,7 +25,7 @@ import java.util.Set;
 import org.jclouds.cloudstack.CloudStackClient;
 import org.jclouds.cloudstack.domain.Zone;
 
-public class Zones {
+public final class Zones {
 
     private Zones() {
     }
@@ -34,7 +34,7 @@ public class Zones {
         Set<Zone> ourZone = Sets.filter(cloudStackClient.getZoneClient().listZones(), new Predicate<Zone>() {
             @Override
             public boolean apply(Zone input) {
-                return input.getName().equals(zoneName);
+                return input != null && input.getName().equals(zoneName);
             }
         });
         return Iterables.getOnlyElement(ourZone).isSecurityGroupsEnabled();

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/test-support/src/main/java/org/apache/provisionr/test/Generics.java
----------------------------------------------------------------------
diff --git a/test-support/src/main/java/org/apache/provisionr/test/Generics.java b/test-support/src/main/java/org/apache/provisionr/test/Generics.java
index 7a29eda..430232e 100644
--- a/test-support/src/main/java/org/apache/provisionr/test/Generics.java
+++ b/test-support/src/main/java/org/apache/provisionr/test/Generics.java
@@ -18,18 +18,17 @@
 
 package org.apache.provisionr.test;
 
+import static com.google.common.base.Preconditions.checkNotNull;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 /**
  * Helper methods for class type parameters.
  *
  * @see <a href="https://github.com/codahale/dropwizard/blob/master/dropwizard-core/src/main/java/com/yammer/dropwizard/util/Generics.java">Generics in Codahale Dropwizard</a>
  * @see <a href="http://gafter.blogspot.com/2006/12/super-type-tokens.html">Super Type Tokens</a>
  */
-public class Generics {
+public final class Generics {
     private Generics() { /* singleton */ }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/test-support/src/main/java/org/apache/provisionr/test/KarafTests.java
----------------------------------------------------------------------
diff --git a/test-support/src/main/java/org/apache/provisionr/test/KarafTests.java b/test-support/src/main/java/org/apache/provisionr/test/KarafTests.java
index fce4faf..d1a0ccc 100644
--- a/test-support/src/main/java/org/apache/provisionr/test/KarafTests.java
+++ b/test-support/src/main/java/org/apache/provisionr/test/KarafTests.java
@@ -36,7 +36,7 @@ import org.ops4j.pax.exam.options.extra.FeaturesScannerProvisionOption;
 /**
  * Helper methods for Karaf integration tests
  */
-public class KarafTests {
+public final class KarafTests {
 
     public static final String KARAF_GROUP_ID = "org.apache.karaf";
     public static final String KARAF_ARTIFACT_ID = "apache-karaf";

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/test-support/src/main/java/org/apache/provisionr/test/ProcessVariablesCollector.java
----------------------------------------------------------------------
diff --git a/test-support/src/main/java/org/apache/provisionr/test/ProcessVariablesCollector.java b/test-support/src/main/java/org/apache/provisionr/test/ProcessVariablesCollector.java
index 607a055..52bb886 100644
--- a/test-support/src/main/java/org/apache/provisionr/test/ProcessVariablesCollector.java
+++ b/test-support/src/main/java/org/apache/provisionr/test/ProcessVariablesCollector.java
@@ -44,7 +44,7 @@ public class ProcessVariablesCollector implements Answer<Void> {
     }
 
     @Override
-    public Void answer(InvocationOnMock invocation) throws Throwable {
+    public Void answer(InvocationOnMock invocation) {
         Object[] arguments = invocation.getArguments();
         LOG.info("Got method call {} with arguments {}",
             invocation.getMethod().getName(), Arrays.toString(arguments));

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/e896d1ca/test-support/src/main/java/org/apache/provisionr/test/TestConstants.java
----------------------------------------------------------------------
diff --git a/test-support/src/main/java/org/apache/provisionr/test/TestConstants.java b/test-support/src/main/java/org/apache/provisionr/test/TestConstants.java
index cd20d8a..245a374 100644
--- a/test-support/src/main/java/org/apache/provisionr/test/TestConstants.java
+++ b/test-support/src/main/java/org/apache/provisionr/test/TestConstants.java
@@ -23,7 +23,10 @@ import com.google.common.base.Throwables;
 import com.google.common.io.Resources;
 import java.io.IOException;
 
-public class TestConstants {
+public final class TestConstants {
+
+    private TestConstants() {
+    }
 
     static final String PUBLIC_KEY_FILE_NAME = "id_rsa_test.pub";
     static final String PRIVATE_KEY_FILE_NAME = "id_rsa_test";


Mime
View raw message