This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by 
this push:
     new ca74819  AMBARI-22883. NPE in HostResourceDefinition (#458)
ca74819 is described below

commit ca74819d5167bf81030bb6130ab6c24d5f793423
Author: Doroszlai, Attila <6454655+adorosz...@users.noreply.github.com>
AuthorDate: Fri Feb 23 20:12:57 2018 +0100

    AMBARI-22883. NPE in HostResourceDefinition (#458)
---
 .../server/api/resources/DetachedHostResourceDefinition.java   |  3 ++-
 .../ambari/server/api/resources/HostResourceDefinition.java    |  3 ++-
 .../server/api/resources/HostResourceDefinitionTest.java       | 10 ++++++++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/DetachedHostResourceDefinition.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/DetachedHostResourceDefinition.java
index 35e237c..1d19ff1 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/DetachedHostResourceDefinition.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/DetachedHostResourceDefinition.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.api.resources;
 
 import org.apache.ambari.server.api.query.render.HostSummaryRenderer;
 import org.apache.ambari.server.api.query.render.Renderer;
+import org.apache.ambari.server.controller.internal.HostResourceProvider;
 import org.apache.ambari.server.controller.spi.Resource;
 
 
@@ -45,7 +46,7 @@ public class DetachedHostResourceDefinition extends 
BaseResourceDefinition {
 
   @Override
   public Renderer getRenderer(String name) {
-    if (name.equals("summary")) {
+    if (HostResourceProvider.SUMMARY_PROPERTY_ID.equals(name)) {
       return new HostSummaryRenderer();
     }
     return super.getRenderer(name);
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java
index 46ca04a..d8c92af 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/HostResourceDefinition.java
@@ -26,6 +26,7 @@ import java.util.Set;
 
 import org.apache.ambari.server.api.query.render.HostSummaryRenderer;
 import org.apache.ambari.server.api.query.render.Renderer;
+import org.apache.ambari.server.controller.internal.HostResourceProvider;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
 
@@ -58,7 +59,7 @@ public class HostResourceDefinition extends 
BaseResourceDefinition {
 
   @Override
   public Renderer getRenderer(String name) {
-    if (name.equals("summary")) {
+    if (HostResourceProvider.SUMMARY_PROPERTY_ID.equals(name)) {
       return new HostSummaryRenderer();
     }
     return super.getRenderer(name);
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/HostResourceDefinitionTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/HostResourceDefinitionTest.java
index c028749..f6dbd58 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/HostResourceDefinitionTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/HostResourceDefinitionTest.java
@@ -19,10 +19,13 @@
 package org.apache.ambari.server.api.resources;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Set;
 
+import org.apache.ambari.server.api.query.render.DefaultRenderer;
+import org.apache.ambari.server.api.query.render.HostSummaryRenderer;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.junit.Test;
 
@@ -53,6 +56,13 @@ public class HostResourceDefinitionTest {
     assertTrue(includesType(subResources, Resource.Type.HostKerberosIdentity));
   }
 
+  @Test
+  public void getRenderer() {
+    ResourceDefinition resource = new HostResourceDefinition();
+    assertSame(HostSummaryRenderer.class, 
resource.getRenderer("summary").getClass());
+    assertSame(DefaultRenderer.class, resource.getRenderer(null).getClass());
+  }
+
   private boolean includesType(Set<SubResourceDefinition> resources, 
Resource.Type type) {
     for (SubResourceDefinition subResource : resources) {
       if (subResource.getType() == type) {

-- 
To stop receiving notification emails like this one, please contact
adorosz...@apache.org.

Reply via email to