Announcement Announcement Module
Collapse
No announcement yet.
readMethod invocation causes problem in bean creation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • readMethod invocation causes problem in bean creation

    After upgrading to spring 1.2.3, the creation of my OSWorkflow bean failed. I tracked this down to some (new?) behavior in BeanWrapperImpl#setPropertyValue() (line 836): Before setting the supplied value/bean (i.e. foo via setFoo()) , the corresponding read method (getFoo()) is invoked. If getFoo() has side effects (or falls back to some unwanted default behavior as it is the case with OSWorkflow) you have - at least in your logs - some nasty NPEs or stuff like this.

    It would be great if the retrieval of the "oldValue" could be switched off. I assume it is relevant to the binding i.e. in the Spring MVC environment but quite unwanted in the "normal" bean creation via the XML config files.

    Or do I miss something completely here?

    Sebastian

  • #2
    Indeed, this behavior that we introduced in Spring 1.2.3 can have side effects, in particular for getters that internally initialize some default state. While this isn't entirely appropriate for public bean property getters, which should allow follow-up setter invocations without any side effects, it's not untypical for configuration properties to expose such fallback behavior. In most cases, the getter invocation only leads to debug log entries, as you noted - but in specific cases, it can lead to unwanted default initialization.

    For this reason, I've refined this for the upcoming Spring 1.2.4: BeanWrapper will by default only expose old values to property editors when used through DataBinder, i.e. for data binding from a (web) request. It will by default not apply that behavior within a BeanFactory. The defaults can be overridden through the "BeanWrapper.setExtractOldValueForEditor" flag, but that should hardly be necessary - given the new defaults.

    I've already committed this to CVS; this refinement should be available in the next nightly snapshot. Please give one of the next 1.2.4 snapshots a try, and let me know whether initialization of OSWorkflow works for you again!

    Juergen

    Comment


    • #3
      Thank you Juergen for your efforts. I'm going to check this with a new version in the next days: Right now, I can't find an August snapshot -- I'll keep looking...

      Thanks,
      Sebastian

      Comment

      Working...
      X