diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryReference.java b/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryReference.java index 35c3d3f51f..c2c0a7c629 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryReference.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/access/BeanFactoryReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.beans.factory.access; -import org.springframework.beans.FatalBeanException; import org.springframework.beans.factory.BeanFactory; /** @@ -49,11 +48,10 @@ public interface BeanFactoryReference { *
In an EJB usage scenario this would normally be called from * {@code ejbRemove()} and {@code ejbPassivate()}. *
This is safe to call multiple times. - * @throws FatalBeanException if the {@code BeanFactory} cannot be released * @see BeanFactoryLocator * @see org.springframework.context.access.ContextBeanFactoryReference * @see org.springframework.context.ConfigurableApplicationContext#close() */ - void release() throws FatalBeanException; + void release(); } diff --git a/spring-context/src/main/java/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.java b/spring-context/src/main/java/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.java index 89d5067451..33c1596630 100644 --- a/spring-context/src/main/java/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.java +++ b/spring-context/src/main/java/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,8 +71,6 @@ import org.springframework.context.access.ContextSingletonBeanFactoryLocator; * @see org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator * @see #getBeanFactoryLocatorKey - * @see org.springframework.ejb.support.AbstractEnterpriseBean#setBeanFactoryLocator - * @see org.springframework.ejb.support.AbstractEnterpriseBean#setBeanFactoryLocatorKey */ public class SpringBeanAutowiringInterceptor { @@ -99,9 +97,15 @@ public class SpringBeanAutowiringInterceptor { invocationContext.proceed(); } catch (RuntimeException ex) { + doReleaseBean(invocationContext.getTarget()); throw ex; } + catch (Error err) { + doReleaseBean(invocationContext.getTarget()); + throw err; + } catch (Exception ex) { + doReleaseBean(invocationContext.getTarget()); // Cannot declare a checked exception on WebSphere here - so we need to wrap. throw new EJBException(ex); }