You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by jj...@apache.org on 2017/02/14 08:41:36 UTC

eagle git commit: [EAGLE-892] fixng NPE on ResourceFetcher

Repository: eagle
Updated Branches:
  refs/heads/master 1cfff2b9a -> ac5776750


[EAGLE-892] fixng NPE on ResourceFetcher

MRRunningJobFetchSpout uses these functions which if returned Null, the follow up log line will throw NPE. ( as shown below )
```
apps = resourceFetcher.getResource(Constants.ResourceType.RUNNING_MR_JOB);
LOG.info("get {} apps from resource manager", apps.size());
```

Author: Jay <jh...@gmail.com>

Closes #800 from jhsenjaliya/EAGLE-892.


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

Branch: refs/heads/master
Commit: ac577675017a6ef437b8a774aa2c0e43cc973502
Parents: 1cfff2b
Author: Jay <jh...@gmail.com>
Authored: Tue Feb 14 08:41:13 2017 +0000
Committer: r7raul1984 <ta...@yhd.com>
Committed: Tue Feb 14 08:41:13 2017 +0000

----------------------------------------------------------------------
 .../eagle/jpm/util/resourcefetch/RMResourceFetcher.java  | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/eagle/blob/ac577675/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
----------------------------------------------------------------------
diff --git a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
index 10d7c58..225ede9 100644
--- a/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
+++ b/eagle-jpm/eagle-jpm-util/src/main/java/org/apache/eagle/jpm/util/resourcefetch/RMResourceFetcher.java
@@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.List;
 
 public class RMResourceFetcher implements ResourceFetcher<AppInfo> {
@@ -66,7 +67,7 @@ public class RMResourceFetcher implements ResourceFetcher<AppInfo> {
     }
 
     private List<AppInfo> doFetchFinishApplicationsList(String urlString, Constants.CompressionType compressionType) throws Exception {
-        List<AppInfo> result;
+        List<AppInfo> result = new ArrayList<>(0);
         InputStream is = null;
         try {
             checkUrl();
@@ -76,9 +77,8 @@ public class RMResourceFetcher implements ResourceFetcher<AppInfo> {
             if (appWrapper != null && appWrapper.getApps() != null
                 && appWrapper.getApps().getApp() != null) {
                 result = appWrapper.getApps().getApp();
-                return result;
             }
-            return null;
+            return result;
         } finally {
             if (is != null) {
                 try {
@@ -113,7 +113,7 @@ public class RMResourceFetcher implements ResourceFetcher<AppInfo> {
     }
 
     private List<AppInfo> doFetchRunningApplicationsList(String urlString, Constants.CompressionType compressionType) throws Exception {
-        List<AppInfo> result;
+        List<AppInfo> result = new ArrayList<>(0);
         InputStream is = null;
         try {
             checkUrl();
@@ -122,9 +122,8 @@ public class RMResourceFetcher implements ResourceFetcher<AppInfo> {
             final AppsWrapper appWrapper = OBJ_MAPPER.readValue(is, AppsWrapper.class);
             if (appWrapper != null && appWrapper.getApps() != null && appWrapper.getApps().getApp() != null) {
                 result = appWrapper.getApps().getApp();
-                return result;
             }
-            return null;
+            return result;
         } finally {
             if (is != null) {
                 try {