remove leftover ObjectOutputStream references
This commit is contained in:
parent
325cc6bc61
commit
0148c462e0
|
@ -1224,97 +1224,6 @@ public class Base64 {
|
||||||
} // end decode
|
} // end decode
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to decode Base64 data and deserialize a Java
|
|
||||||
* Object within. Returns <tt>null</tt> if there was an error.
|
|
||||||
*
|
|
||||||
* @param encodedObject The Base64 data to decode
|
|
||||||
* @return The decoded and deserialized object
|
|
||||||
* @throws NullPointerException if encodedObject is null
|
|
||||||
* @throws java.io.IOException if there is a general error
|
|
||||||
* @throws ClassNotFoundException if the decoded object is of a
|
|
||||||
* class that cannot be found by the JVM
|
|
||||||
* @since 1.5
|
|
||||||
*/
|
|
||||||
public static Object decodeToObject(String encodedObject)
|
|
||||||
throws java.io.IOException, java.lang.ClassNotFoundException {
|
|
||||||
return decodeToObject(encodedObject, NO_OPTIONS, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to decode Base64 data and deserialize a Java
|
|
||||||
* Object within. Returns <tt>null</tt> if there was an error.
|
|
||||||
* If <tt>loader</tt> is not null, it will be the class loader
|
|
||||||
* used when deserializing.
|
|
||||||
*
|
|
||||||
* @param encodedObject The Base64 data to decode
|
|
||||||
* @param options Various parameters related to decoding
|
|
||||||
* @param loader Optional class loader to use in deserializing classes.
|
|
||||||
* @return The decoded and deserialized object
|
|
||||||
* @throws NullPointerException if encodedObject is null
|
|
||||||
* @throws java.io.IOException if there is a general error
|
|
||||||
* @throws ClassNotFoundException if the decoded object is of a
|
|
||||||
* class that cannot be found by the JVM
|
|
||||||
* @since 2.3.4
|
|
||||||
*/
|
|
||||||
public static Object decodeToObject(
|
|
||||||
String encodedObject, int options, final ClassLoader loader)
|
|
||||||
throws java.io.IOException, java.lang.ClassNotFoundException {
|
|
||||||
|
|
||||||
// Decode and gunzip if necessary
|
|
||||||
byte[] objBytes = decode(encodedObject, options);
|
|
||||||
|
|
||||||
java.io.ByteArrayInputStream bais = null;
|
|
||||||
java.io.ObjectInputStream ois = null;
|
|
||||||
Object obj = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
bais = new java.io.ByteArrayInputStream(objBytes);
|
|
||||||
|
|
||||||
// If no custom class loader is provided, use Java's builtin OIS.
|
|
||||||
if (loader == null) {
|
|
||||||
ois = new java.io.ObjectInputStream(bais);
|
|
||||||
} // end if: no loader provided
|
|
||||||
|
|
||||||
// Else make a customized object input stream that uses
|
|
||||||
// the provided class loader.
|
|
||||||
else {
|
|
||||||
ois = new java.io.ObjectInputStream(bais) {
|
|
||||||
@Override
|
|
||||||
public Class<?> resolveClass(java.io.ObjectStreamClass streamClass)
|
|
||||||
throws java.io.IOException, ClassNotFoundException {
|
|
||||||
Class<?> c = Class.forName(streamClass.getName(), false, loader);
|
|
||||||
if (c == null) {
|
|
||||||
return super.resolveClass(streamClass);
|
|
||||||
} else {
|
|
||||||
return c; // Class loader knows of this class.
|
|
||||||
} // end else: not null
|
|
||||||
} // end resolveClass
|
|
||||||
}; // end ois
|
|
||||||
} // end else: no custom class loader
|
|
||||||
|
|
||||||
obj = ois.readObject();
|
|
||||||
} // end try
|
|
||||||
catch (java.io.IOException e) {
|
|
||||||
throw e; // Catch and throw in order to execute finally{}
|
|
||||||
} // end catch
|
|
||||||
catch (java.lang.ClassNotFoundException e) {
|
|
||||||
throw e; // Catch and throw in order to execute finally{}
|
|
||||||
} // end catch
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
bais.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
ois.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
} // end finally
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
} // end decodeObject
|
|
||||||
|
|
||||||
/* ******** I N N E R C L A S S I N P U T S T R E A M ******** */
|
/* ******** I N N E R C L A S S I N P U T S T R E A M ******** */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue