diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java index b766b2145..7c89b61d7 100644 --- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java +++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java @@ -25,6 +25,8 @@ import java.io.ObjectOutputStream; import java.io.ObjectStreamClass; import java.io.OutputStream; import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; /** *
Assists with the serialization process and performs additional functionality based @@ -234,8 +236,10 @@ public class SerializationUtils { * class here is a workaround, see the JIRA issue LANG-626.
*/ static class ClassLoaderAwareObjectInputStream extends ObjectInputStream { + private static final MapInputStream
.
@@ -246,6 +250,16 @@ public class SerializationUtils {
public ClassLoaderAwareObjectInputStream(InputStream in, ClassLoader classLoader) throws IOException {
super(in);
this.classLoader = classLoader;
+
+ primitiveTypes.put("byte", byte.class);
+ primitiveTypes.put("short", short.class);
+ primitiveTypes.put("int", int.class);
+ primitiveTypes.put("long", long.class);
+ primitiveTypes.put("float", float.class);
+ primitiveTypes.put("double", double.class);
+ primitiveTypes.put("boolean", boolean.class);
+ primitiveTypes.put("char", char.class);
+ primitiveTypes.put("void", void.class);
}
/**
@@ -262,7 +276,15 @@ public class SerializationUtils {
try {
return Class.forName(name, false, classLoader);
} catch (ClassNotFoundException ex) {
- return Class.forName(name, false, Thread.currentThread().getContextClassLoader());
+ try {
+ return Class.forName(name, false, Thread.currentThread().getContextClassLoader());
+ } catch (ClassNotFoundException cnfe) {
+ Class> cls = primitiveTypes.get(name);
+ if (cls != null)
+ return cls;
+ else
+ throw cnfe;
+ }
}
}
diff --git a/src/site/changes/changes.xml b/src/site/changes/changes.xml
index e859411ae..ec922c60c 100644
--- a/src/site/changes/changes.xml
+++ b/src/site/changes/changes.xml
@@ -22,6 +22,7 @@