Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4554

Spring BeanPostProcessor(s) are called twice for Struts constructed objects.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.24
    • 2.3.28, 2.5
    • Plugin - Spring
    • None

    Description

      It appears that the SpringObjectFactory in the xwork core at lines 194-197 manually yet when calling initializeBean on the autowire factory, the spring framework automatically invokes these processors too which lead to the following post processor's callbacks being invoked twice for both the before and after handlers.

      I confirmed that both Sprnig 3.0.5 and 4.2.1 have called the bean post processors when the initializeBean function is called. See a simple NullBeanPostProcessor implementation below that can be used as a simple test of post processor invocation.

      NullBeanPostProcessor.java
      import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;
      import org.springframework.beans.BeansException;
      import org.springframework.beans.factory.config.BeanPostProcessor;
      
      /**
       * @since	7.0.0
       */
      public class NullBeanPostProcessor implements BeanPostProcessor {
      
      	private static final Logger LOGGER = LoggerFactory.getLogger(NullBeanPostProcessor.class);
      	
      	/**
      	 * {@inheritDoc}
      	 */
      	@Override
      	public Object postProcessBeforeInitialization(Object bean, String beanName)
      	throws BeansException {
      		LOGGER.debug("Before Initialization for {} ({})", beanName, bean);
      		return bean;
      	}
      
      	/**
      	 * {@inheritDoc}
      	 */
      	@Override
      	public Object postProcessAfterInitialization(Object bean, String beanName)
      	throws BeansException {
      		LOGGER.debug("After Initialization for {} ({})", beanName, bean);
      		return bean;
      	}
      
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            crancran Chris Cranford
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: