karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [3/3] karaf git commit: Avoid possible NPE
Date Wed, 06 Sep 2017 06:18:24 GMT
Avoid possible NPE

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

Branch: refs/heads/master
Commit: 2e5ba176e38581342d45a44dfdcc261dbc9d09e1
Parents: b2d5c5b
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Tue Sep 5 17:39:31 2017 +0200
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Wed Sep 6 08:17:55 2017 +0200

----------------------------------------------------------------------
 .../impl/action/command/DefaultActionPreparator.java   | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/2e5ba176/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/DefaultActionPreparator.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/DefaultActionPreparator.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/DefaultActionPreparator.java
index 5d270e9..313e2a2 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/DefaultActionPreparator.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/DefaultActionPreparator.java
@@ -399,12 +399,15 @@ public class DefaultActionPreparator {
     }
 
     public Object getDefaultValue(Action action, Field field) {
-        try {
-            field.setAccessible(true);
-            return field.get(action);
-        } catch (Exception e) {
-            return null;
+        if (field != null) {
+            try {
+                field.setAccessible(true);
+                return field.get(action);
+            } catch (Exception e) {
+                return null;
+            }
         }
+        return null;
     }
 
     private String loadDescription(Class<?> clazz, String desc) {


Mime
View raw message