AMBARI-18028. Failed to load stack versions (aonishuk)

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

Branch: refs/heads/branch-2.4
Commit: 234fa6aa9236e12b2faf3fb5a163b2c245f4b183
Parents: 264bb25
Author: Andrew Onishuk <[email protected]>
Authored: Fri Aug 5 16:07:31 2016 +0300
Committer: Andrew Onishuk <[email protected]>
Committed: Fri Aug 5 16:07:31 2016 +0300

----------------------------------------------------------------------
 .../server/controller/AmbariHandlerList.java    |  8 +---
 .../apache/ambari/view/utils/hdfs/HdfsUtil.java | 41 +++++++++++---------
 2 files changed, 25 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/234fa6aa/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
index b33d977..ef473d5 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariHandlerList.java
@@ -140,10 +140,8 @@ public class AmbariHandlerList extends HandlerCollection 
implements ViewInstance
     } else {
       // if there is a view target (as in a view resource request) then set 
the view class loader
       ClassLoader contextClassLoader = 
Thread.currentThread().getContextClassLoader();
-      ClassLoader viewClassLoader    = null;
-
       try {
-        viewClassLoader = viewEntity.getClassLoader();
+        ClassLoader viewClassLoader = viewEntity.getClassLoader();
         if (viewClassLoader == null) {
           LOG.debug("No class loader associated with view " + 
viewEntity.getName() + ".");
         } else {
@@ -151,9 +149,7 @@ public class AmbariHandlerList extends HandlerCollection 
implements ViewInstance
         }
         processHandlers(target, baseRequest, request, response);
       } finally {
-        if (viewClassLoader != null) {
-          Thread.currentThread().setContextClassLoader(contextClassLoader);
-        }
+        Thread.currentThread().setContextClassLoader(contextClassLoader);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/234fa6aa/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/HdfsUtil.java
----------------------------------------------------------------------
diff --git 
a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/HdfsUtil.java
 
b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/HdfsUtil.java
index c7d054f..8bc3ca5 100644
--- 
a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/HdfsUtil.java
+++ 
b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/hdfs/HdfsUtil.java
@@ -114,27 +114,32 @@ public class HdfsUtil {
    */
   public static synchronized HdfsApi connectToHDFSApi(ViewContext context) 
throws HdfsApiException {
     HdfsApi api = null;
+    ClassLoader currentClassLoader = 
Thread.currentThread().getContextClassLoader();
     Thread.currentThread().setContextClassLoader(null);
-
-    ConfigurationBuilder configurationBuilder = new 
ConfigurationBuilder(context);
-    AuthConfigurationBuilder authConfigurationBuilder = new 
AuthConfigurationBuilder(context);
-
-    Map<String, String> authParams = authConfigurationBuilder.build();
-    configurationBuilder.setAuthParams(authParams);
-
     try {
-      api = new HdfsApi(configurationBuilder, getHdfsUsername(context));
-      LOG.info("HdfsApi connected OK");
-    } catch (IOException e) {
-      String message = "HDFS040 Couldn't open connection to HDFS";
-      LOG.error(message);
-      throw new HdfsApiException(message, e);
-    } catch (InterruptedException e) {
-      String message = "HDFS041 Couldn't open connection to HDFS";
-      LOG.error(message);
-      throw new HdfsApiException(message, e);
+      ConfigurationBuilder configurationBuilder = new 
ConfigurationBuilder(context);
+      AuthConfigurationBuilder authConfigurationBuilder = new 
AuthConfigurationBuilder(context);
+
+      Map<String, String> authParams = authConfigurationBuilder.build();
+      configurationBuilder.setAuthParams(authParams);
+
+      try {
+        api = new HdfsApi(configurationBuilder, getHdfsUsername(context));
+        LOG.info("HdfsApi connected OK");
+      } catch (IOException e) {
+        String message = "HDFS040 Couldn't open connection to HDFS";
+        LOG.error(message);
+        throw new HdfsApiException(message, e);
+      } catch (InterruptedException e) {
+        String message = "HDFS041 Couldn't open connection to HDFS";
+        LOG.error(message);
+        throw new HdfsApiException(message, e);
+      }
+      return api;
+    }
+    finally {
+      Thread.currentThread().setContextClassLoader(currentClassLoader);
     }
-    return api;
   }
 
   /**

Reply via email to