Wicket
  1. Wicket
  2. WICKET-603

Injecting a reference to a bean which is of a final class fails

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.6
    • Fix Version/s: 1.3.0-beta2
    • Component/s: wicket-spring
    • Labels:
      None

      Description

      When using the @SpringBean annotation, injecting a bean that is of a final class such as String, fails. This is because LazyInitProxyFactory tries to create a subclass of the bean which will obviously fail when that class is marked final.

      A possible fix would be to test the modifiers of the injected field for Modifier.isFinal(..), when this is true don't create a proxy but return the object directly.

        Issue Links

          Activity

          Hide
          Alastair Maw added a comment -

          If they're not careful, people can obviously make a final class that is ApplicationContextAware, and we'll end up serializing the entire context, which is bad.

          The use of Strings as Beans is very odd - taking dependency injection a bit too far, IMHO. If you have a good use case, I guess we could special-case String. You could always have a factory bean which returned the String, though. I think that would be proxyable.

          Show
          Alastair Maw added a comment - If they're not careful, people can obviously make a final class that is ApplicationContextAware, and we'll end up serializing the entire context, which is bad. The use of Strings as Beans is very odd - taking dependency injection a bit too far, IMHO. If you have a good use case, I guess we could special-case String. You could always have a factory bean which returned the String, though. I think that would be proxyable.
          Hide
          Alastair Maw added a comment -

          Fixed for Strings only in r546147.

          Show
          Alastair Maw added a comment - Fixed for Strings only in r546147.
          Hide
          Matthijs Wensveen added a comment -

          Thanks for fixing this. I sometimes use spring to inject configuration values too, which might be mis-use of spring, but works quite well.

          Special-casing String is fine by me, as that is the only case I ever use

          Show
          Matthijs Wensveen added a comment - Thanks for fixing this. I sometimes use spring to inject configuration values too, which might be mis-use of spring, but works quite well. Special-casing String is fine by me, as that is the only case I ever use

            People

            • Assignee:
              Alastair Maw
              Reporter:
              Matthijs Wensveen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development