From 46af959c3f7fee0fa77e00d87892baa634971969 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 7 May 2008 18:11:38 +0000 Subject: [PATCH] HHH-3261 : fixed wrapping of exception from initialize/destory listeners git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14648 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../org/hibernate/event/EventListeners.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/hibernate/event/EventListeners.java b/core/src/main/java/org/hibernate/event/EventListeners.java index fd2c598e4a..f44d4f62cb 100644 --- a/core/src/main/java/org/hibernate/event/EventListeners.java +++ b/core/src/main/java/org/hibernate/event/EventListeners.java @@ -29,7 +29,6 @@ import java.util.Collections; 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,18 +161,23 @@ public class EventListeners extends Cloneable implements Serializable { 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 @@ public class EventListeners extends Cloneable implements Serializable { } } + /** + * Call {@link Destructible#cleanup} on any listeners that implement the + * {@link Destructible} interface. + */ public void destroyListeners() { try { processListeners(