Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2263

IOC decorator matching bug

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 5.4
    • Fix Version/s: None
    • Component/s: tapestry-ioc
    • Labels:

      Description

      In our implementation we have a factory service CacheFactory, with markers, that is injected into a Cache service with the same markers (say @MarkerA). In tests, I wish to replace the CacheFactory with

      @Decorate
      @MarkerA
      public CacheFactory decorate(...) {}

      However I get an error that the decorate method returns the wrong type.

      The cause is that the matching of the decorators in the module implementation does not match on ServiceDef and markers. Specifically in

      ModuleImpl.findMatchingDecoratorDefs there is a condition

      if (def.matches(serviceDef) || markerMatched(serviceDef, InternalUtils.toDecoratorDef2(def)))
      result.add(def);

      which needs to be

      if (def.matches(serviceDef) && markerMatched(serviceDef, InternalUtils.toDecoratorDef2(def)))
      result.add(def);

      to fix the problem. With the || it matches unrelated service definitions with the same markers.

      Thanks!

        Attachments

          Activity

            People

            • Assignee:
              jkemnade Jochen Kemnade
              Reporter:
              adriaanjoubert Adriaan Joubert
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: