karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf git commit: [KARAF-4687] Fix NPE with IBM Java
Date Thu, 15 Sep 2016 06:49:15 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x 46c08f1c7 -> 89c575ca8


[KARAF-4687] Fix NPE with IBM Java


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

Branch: refs/heads/karaf-4.0.x
Commit: 89c575ca8b51b22393353a2d504488edd5906980
Parents: 46c08f1
Author: Grzegorz Grzybek <ggrzybek@redhat.com>
Authored: Wed Sep 14 17:46:20 2016 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Thu Sep 15 08:49:00 2016 +0200

----------------------------------------------------------------------
 .../src/main/java/java/lang/Exception.java      | 21 ++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/89c575ca/exception/src/main/java/java/lang/Exception.java
----------------------------------------------------------------------
diff --git a/exception/src/main/java/java/lang/Exception.java b/exception/src/main/java/java/lang/Exception.java
index d07c280..940658b 100644
--- a/exception/src/main/java/java/lang/Exception.java
+++ b/exception/src/main/java/java/lang/Exception.java
@@ -36,7 +36,7 @@ import javax.xml.bind.annotation.XmlTransient;
 public class Exception extends Throwable {
     private static final long serialVersionUID = -3387516993124229948L;
 
-    private transient Reference<Class<?>>[] classContext;
+    private transient Reference<Class<?>>[] classContext = null;
 
     /**
      * Constructs a new {@code Exception} that includes the current stack trace.
@@ -127,10 +127,13 @@ public class Exception extends Throwable {
     @XmlTransient
     @Deprecated
     public Class[] getClassContext() {
-        Class<?>[] context = new Class<?>[classContext.length];
-        for (int i = 0; i < classContext.length; i++) {
-            Class<?> c = classContext[i].get();
-            context[i] = c == null ? Object.class : c;
+        Class<?>[] context = null;
+        if (classContext != null) {
+            context = new Class<?>[classContext.length];
+            for (int i = 0; i < classContext.length; i++) {
+                Class<?> c = classContext[i].get();
+                context[i] = c == null ? Object.class : c;
+            }
         }
         return context;
     }
@@ -138,9 +141,11 @@ public class Exception extends Throwable {
     @SuppressWarnings("unchecked")
     private void initClassContext() {
         Class[] context = SecurityManagerEx.getInstance().getThrowableContext(this);
-        classContext = new Reference[context.length];
-        for (int i = 0; i < context.length; i++) {
-            classContext[i] = new WeakReference<Class<?>>(context[i]);
+        if (context != null) {
+            classContext = new Reference[context.length];
+            for (int i = 0; i < context.length; i++) {
+                classContext[i] = new WeakReference<Class<?>>(context[i]);
+            }
         }
     }
     


Mime
View raw message