HHH-5195 : FilterImpl.validate() throws NullPointerException on deserialization

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19727 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Gail Badner 2010-06-15 02:15:05 +00:00
parent 06f9e60a0a
commit 182ee2f34e
2 changed files with 39 additions and 0 deletions

View File

@ -129,6 +129,43 @@ public abstract class ConnectionManagementTestCase extends FunctionalTestCase {
}
}
/**
* Tests to validate that a session holding JDBC resources will not
* be allowed to serialize.
*/
public final void testEnabledFilterSerialization() throws Throwable {
prepare();
Session sessionUnderTest = getSessionUnderTest();
sessionUnderTest.enableFilter( "nameIsNull" );
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
sessionUnderTest.disconnect();
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
byte[] bytes = SerializationHelper.serialize( sessionUnderTest );
checkSerializedState( sessionUnderTest );
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
reconnect( sessionUnderTest );
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
sessionUnderTest.disconnect();
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
Session s2 = ( Session ) SerializationHelper.deserialize( bytes );
checkDeserializedState( s2 );
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
reconnect( s2 );
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
s2.disconnect();
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
reconnect( s2 );
assertNotNull( sessionUnderTest.getEnabledFilter( "nameIsNull" ) );
release( sessionUnderTest );
release( s2 );
done();
}
/**
* Test that a session which has been manually disconnected will be allowed
* to serialize.

View File

@ -20,4 +20,6 @@
<property name="name"/>
</class>
<filter-def name="nameIsNull" condition="name is null" />
</hibernate-mapping>