Spring JavaConfig
  1. Spring JavaConfig
  2. SJC-239

Using @AnnotationDrivenTx in conjunction with @ExternalValue fields does not work

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Issue Links

        Activity

        Hide
        Chris Beams added a comment -

        This issue is caused by the fact that @AnnotationDrivenTx is handled in order before @*ValueSource annotations (ordering appears to be alphabetical).

        The processing of @AnnotationDrivenTx causes certain beans to be instantiated (in order to be proxied) and so any beans that needed @ExternalValues end up getting nulls instead. Later, during processing of @*ValueSource annotations, the @ExternalValue fields do get assigned, but it's too late at that point.

        The solution here is to allow for explicit ordering of @Plugin annotations. This will be addressed by a separate issue.

        Show
        Chris Beams added a comment - This issue is caused by the fact that @AnnotationDrivenTx is handled in order before @*ValueSource annotations (ordering appears to be alphabetical). The processing of @AnnotationDrivenTx causes certain beans to be instantiated (in order to be proxied) and so any beans that needed @ExternalValues end up getting nulls instead. Later, during processing of @*ValueSource annotations, the @ExternalValue fields do get assigned, but it's too late at that point. The solution here is to allow for explicit ordering of @Plugin annotations. This will be addressed by a separate issue.
        Hide
        Chris Beams added a comment -

        Resolved, see AnnotationDrivenTxWithExternalValueTests. Subject to further refactoring, but functions as expected. Also note that the comment above was not quite accurate. The core issue was that injection of ExternalValues was being done by a BeanPostProcessor, but AnnotationDrivenTx proxying was being kicked off by a BeanFactoryPostProcessor. One way or another, the @Configuration class instance was being eagerly instantiated during the processing of @AnnotationDrivenTx, but was not being BeanPostProcessed. This could be something to take up with the core framework, but the issue has been resolved entirely by taking a new approach. ExternalValue injection no longer happens via BeanPostProcessing, but is now rather an integral part of the enhancement lifecycle (see CglibConfigurationEnhancer).

        Show
        Chris Beams added a comment - Resolved, see AnnotationDrivenTxWithExternalValueTests. Subject to further refactoring, but functions as expected. Also note that the comment above was not quite accurate. The core issue was that injection of ExternalValues was being done by a BeanPostProcessor, but AnnotationDrivenTx proxying was being kicked off by a BeanFactoryPostProcessor. One way or another, the @Configuration class instance was being eagerly instantiated during the processing of @AnnotationDrivenTx, but was not being BeanPostProcessed. This could be something to take up with the core framework, but the issue has been resolved entirely by taking a new approach. ExternalValue injection no longer happens via BeanPostProcessing, but is now rather an integral part of the enhancement lifecycle (see CglibConfigurationEnhancer).

          People

          • Assignee:
            Chris Beams
            Reporter:
            Chris Beams
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development