ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject git commit: AMBARI-6700 Rest API Null Pointer Exception for non-existent host in HostRoles/host_name filter for host_components (rjaltare via jaoki)
Date Mon, 27 Oct 2014 19:58:16 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c0c738072 -> 148f5a9b8


AMBARI-6700 Rest API Null Pointer Exception for non-existent host in HostRoles/host_name filter
for host_components (rjaltare via jaoki)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/148f5a9b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/148f5a9b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/148f5a9b

Branch: refs/heads/trunk
Commit: 148f5a9b8ea0ba666b485c2080ace556a7dbf5b1
Parents: c0c7380
Author: Jun Aoki <jaoki@apache.org>
Authored: Mon Oct 27 12:58:05 2014 -0700
Committer: Jun Aoki <jaoki@apache.org>
Committed: Mon Oct 27 12:58:05 2014 -0700

----------------------------------------------------------------------
 .../org/apache/ambari/server/state/cluster/ClustersImpl.java | 3 +++
 .../org/apache/ambari/server/state/cluster/ClustersTest.java | 8 ++++++++
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/148f5a9b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
index a57e9c2..4cfa308 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
@@ -286,6 +286,9 @@ public class ClustersImpl implements Clusters {
     checkLoaded();
     r.lock();
     try {
+      if(!hostClusterMap.containsKey(hostname)){
+            throw new HostNotFoundException(hostname);
+      }
       if (LOG.isDebugEnabled()) {
         LOG.debug("Looking up clusters for hostname"
             + ", hostname=" + hostname

http://git-wip-us.apache.org/repos/asf/ambari/blob/148f5a9b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
index 2baa5c5..f90c2c5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
@@ -203,6 +203,7 @@ public class ClustersTest {
     String h1 = "h1";
     String h2 = "h2";
     String h3 = "h3";
+    String h4 = "h4";
 
     try {
       clusters.mapHostToCluster(h1, c1);
@@ -235,6 +236,13 @@ public class ClustersTest {
     clusters.getHost(h2).persist();
     clusters.getHost(h3).persist();
 
+    try {
+        clusters.getClustersForHost(h4);
+        fail("Expected exception for invalid host");
+    } catch (HostNotFoundException e) {
+          // Expected
+    }
+
     Set<Cluster> c = clusters.getClustersForHost(h3);
     Assert.assertEquals(0, c.size());
 


Mime
View raw message