HHH-12133 Ignore managed bean release errors related to already released beans

This commit is contained in:
Yoann Rodière 2018-01-08 13:07:18 +01:00 committed by Steve Ebersole
parent bc304235a6
commit be6ac17d1e
1 changed files with 15 additions and 1 deletions

View File

@ -6,11 +6,14 @@
*/
package org.hibernate.resource.beans.internal;
import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.jboss.logging.Logger;
/**
* A {@link CdiLifecycleManagementStrategy} to use when CDI compliance is required
* (i.e. when the bean lifecycle is to be managed by the CDI runtime, not the JPA runtime).
@ -22,6 +25,7 @@ import org.hibernate.resource.beans.spi.ManagedBean;
* and are not duplicated, in contrast to {@link JpaCdiLifecycleManagementStrategy}.
*/
class StandardCdiLifecycleManagementStrategy implements CdiLifecycleManagementStrategy {
private static final Logger log = Logger.getLogger( CompositeManagedBeanRegistry.class );
static final StandardCdiLifecycleManagementStrategy INSTANCE = new StandardCdiLifecycleManagementStrategy();
@ -70,7 +74,17 @@ class StandardCdiLifecycleManagementStrategy implements CdiLifecycleManagementSt
@Override
public void release() {
try {
instance.destroy( beanInstance );
}
catch (ContextNotActiveException e) {
log.debugf(
"Error destroying managed bean instance [%s] - the context is not active anymore."
+ " The instance must have been destroyed already - ignoring.",
instance,
e
);
}
}
}
}