Sfoglia il codice sorgente

AMBARI-15045. NPE in ambari server log related tez view. (dipayanb)

Dipayan Bhowmick 9 anni fa
parent
commit
1dbf7d4ef5

+ 5 - 2
contrib/views/tez/src/main/java/org/apache/ambari/view/tez/utils/ProxyHelper.java

@@ -54,10 +54,13 @@ public class ProxyHelper {
       URLConnectionProvider provider = viewContext.getURLConnectionProvider();
       HttpURLConnection connection = provider.getConnectionAsCurrent(url, "GET", (String) null, headers);
 
-      if(connection.getResponseCode() != Response.Status.OK.getStatusCode()) {
+      if (!(connection.getResponseCode() >= 200 && connection.getResponseCode() < 300)) {
         LOG.error("Failure in fetching results for the URL: {}. Status: {}", url, connection.getResponseCode());
+        String trace = "";
         inputStream = connection.getErrorStream();
-        String trace = IOUtils.toString(inputStream);
+        if (inputStream != null) {
+          trace = IOUtils.toString(inputStream);
+        }
         throw new ProxyException("Failed to fetch results by the proxy from url: " + url, connection.getResponseCode(), trace);
       }