activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r628710 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
Date Mon, 18 Feb 2008 12:55:53 GMT
Author: rajdavies
Date: Mon Feb 18 04:55:51 2008
New Revision: 628710

URL: http://svn.apache.org/viewvc?rev=628710&view=rev
Log:
Apply patch for https://issues.apache.org/activemq/browse/AMQ-1584

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java?rev=628710&r1=628709&r2=628710&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ClassLoadingAwareObjectInputStream.java
Mon Feb 18 04:55:51 2008
@@ -21,11 +21,13 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectStreamClass;
 import java.lang.reflect.Proxy;
+import java.util.HashMap;
 
 public class ClassLoadingAwareObjectInputStream extends ObjectInputStream {
 
     private static final ClassLoader FALLBACK_CLASS_LOADER = ClassLoadingAwareObjectInputStream.class.getClassLoader();
-
+    /** <p>Maps primitive type names to corresponding class objects.</p> */
+    private static final HashMap<String, Class> primClasses = new HashMap<String,
Class>(8, 1.0F);
     public ClassLoadingAwareObjectInputStream(InputStream in) throws IOException {
         super(in);
     }
@@ -49,12 +51,32 @@
         }
     }
 
-    private Class load(String className, ClassLoader cl) throws ClassNotFoundException {
+    private Class load(String className, ClassLoader cl)
+            throws ClassNotFoundException {
         try {
             return Class.forName(className, false, cl);
         } catch (ClassNotFoundException e) {
-            return Class.forName(className, false, FALLBACK_CLASS_LOADER);
+            final Class clazz = (Class) primClasses.get(className);
+            if (clazz != null) {
+                return clazz;
+            } else {
+                return Class.forName(className, false, FALLBACK_CLASS_LOADER);
+            }
         }
+    }
+    
+    
+    
+    static {
+        primClasses.put("boolean", boolean.class);
+        primClasses.put("byte", byte.class);
+        primClasses.put("char", char.class);
+        primClasses.put("short", short.class);
+        primClasses.put("int", int.class);
+        primClasses.put("long", long.class);
+        primClasses.put("float", float.class);
+        primClasses.put("double", double.class);
+        primClasses.put("void", void.class);
     }
 
 }



Mime
View raw message