Author: steve.ebersole(a)jboss.com
Date: 2008-05-07 14:11:38 -0400 (Wed, 07 May 2008)
New Revision: 14648
Modified:
core/trunk/core/src/main/java/org/hibernate/event/EventListeners.java
Log:
HHH-3261 : fixed wrapping of exception from initialize/destory listeners
Modified: core/trunk/core/src/main/java/org/hibernate/event/EventListeners.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/EventListeners.java 2008-05-07
14:31:16 UTC (rev 14647)
+++ core/trunk/core/src/main/java/org/hibernate/event/EventListeners.java 2008-05-07
18:11:38 UTC (rev 14648)
@@ -29,7 +29,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
@@ -162,19 +161,24 @@
private void processListeners(ListenerProcesser processer) {
Field[] fields = getClass().getDeclaredFields();
for ( int i = 0; i < fields.length; i++ ) {
+ final Object[] listeners;
try {
- final Object field = fields[i].get( this );
- if ( field instanceof Object[] ) {
- final Object[] listeners = ( Object[] ) field;
- int length = listeners.length;
- for ( int index = 0 ; index < length ; index++ ) {
- processer.processListener( listeners[index ] );
- }
+ Object fieldValue = fields[i].get(this);
+ if ( fieldValue instanceof Object[] ) {
+ listeners = ( Object[] ) fieldValue;
}
+ else {
+ continue;
+ }
}
- catch ( Exception e ) {
- throw new HibernateException( "could not process listeners", e );
+ catch ( Throwable t ) {
+ throw new HibernateException( "could not init listeners", t );
}
+
+ int length = listeners.length;
+ for ( int index = 0 ; index < length ; index++ ) {
+ processer.processListener( listeners[index ] );
+ }
}
}
@@ -201,6 +205,10 @@
}
}
+ /**
+ * Call {@link Destructible#cleanup} on any listeners that implement the
+ * {@link Destructible} interface.
+ */
public void destroyListeners() {
try {
processListeners(
Show replies by date