Skip to content

Commit

Permalink
fixed files form Lang #13
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 3e389c3 commit 3151d76
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions projects/Lang/13/org/apache/commons/lang3/SerializationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ public static Object deserialize(byte[] objectData) {
* class here is a workaround, see the JIRA issue LANG-626. </p>
*/
static class ClassLoaderAwareObjectInputStream extends ObjectInputStream {
private static final Map<String, Class<?>> primitiveTypes =
new HashMap<String, Class<?>>();
private ClassLoader classLoader;

/**
Expand All @@ -249,6 +251,15 @@ public ClassLoaderAwareObjectInputStream(InputStream in, ClassLoader classLoader
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);
}

/**
Expand All @@ -265,7 +276,15 @@ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, Clas
try {
return Class.forName(name, false, classLoader);
} catch (ClassNotFoundException ex) {
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;
}
}
}

Expand Down

0 comments on commit 3151d76

Please sign in to comment.