Author: steve.ebersole(a)jboss.com
Date: 2009-11-14 13:03:16 -0500 (Sat, 14 Nov 2009)
New Revision: 17984
Modified:
core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.java
Log:
HHH-4572 - check if the connection supports jdbc4 before looking for the createClob
method
Modified: core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.java 2009-11-14
13:20:27 UTC (rev 17983)
+++ core/trunk/core/src/main/java/org/hibernate/util/SerializationHelper.java 2009-11-14
18:03:16 UTC (rev 17984)
@@ -224,7 +224,9 @@
}
/**
- * Deserializes an Object from an array of bytes.
+ * Deserializes an object from an array of bytes using the Thread Context
+ * ClassLoader (TCCL). If there is no TCCL set, the classloader of the calling
+ * class is used.
* <p/>
* Delegates to {@link #deserialize(byte[], ClassLoader)}
*
@@ -238,7 +240,7 @@
}
/**
- * Deserializes an Object from an array of bytes.
+ * Deserializes an object from an array of bytes.
* <p/>
* Delegates to {@link #deserialize(java.io.InputStream, ClassLoader)} using a
* {@link ByteArrayInputStream} to wrap the array.
@@ -261,9 +263,12 @@
/**
- * Custom ObjectInputStream implementation to more appropriately handle classloading
- * within app servers (mainly jboss - hence this class inspired by jboss's class of
- * the same purpose).
+ * By default, to resolve the classes being deserialized JDK serialization uses the
+ * classes loader which loaded the class which initiated the deserialization call.
Here
+ * that would be hibernate classes. However, there are cases where that is not the
correct
+ * class loader to use; mainly here we are worried about deserializing user classes in
+ * environments (app servers, etc) where Hibernate is on a parent classes loader. To
+ * facilitate for that we allow passing in the class loader we should use.
*/
private static final class CustomObjectInputStream extends ObjectInputStream {
private final ClassLoader loader;
@@ -273,10 +278,14 @@
this.loader = loader;
}
+ /**
+ * {@inheritDoc}
+ */
protected Class resolveClass(ObjectStreamClass v) throws IOException,
ClassNotFoundException {
String className = v.getName();
log.trace("Attempting to locate class [" + className + "]");
+ // if we were given a classloader, attempt to use it to resolve the class...
if ( loader != null ) {
try {
return Class.forName( className, false, loader );
@@ -286,6 +295,8 @@
}
}
+ // By default delegate to normal JDK deserialization which will use the class loader
+ // of the class which is calling this deserialization.
return super.resolveClass( v );
}
}
Show replies by date