Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-11860

OsgiServiceUtil may invoke the wrong method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • Testing OSGi Mock 3.3.8
    • Testing
    • None

    Description

      Impacts both the activate/deactivate methods and the bind/unbind methods

      The scenario where this happens is when the parent class has an activate/deactivate/bind/unbind method with one set of arguments  and the subclass has an activate/deactivate/bind/unbind method with the same name but with a different set of arguments.

      For example, when the context.registerInjectActivateService(..) call is invoked,  it finds the activate(Map) method from the parent class and invokes it and then returns instead of calling the more specific activate(Config) methods from the subclass.

      public class ParentComponent {
      
          protected void activate(Map<String, Object> props) {
              // this should not be invoked when activating SubComponent
          }
      
      }
      
      @Component
      @Designate(ocd=SubComponent.Config.class)
      public class SubComponent extends ParentComponent {
      
          @ObjectClassDefinition(name = "SubComponent Config")
          public @interface Config {
              @AttributeDefinition(name = "Prop One")
              boolean prop1() default true;
          }
      
          @Activate
          protected void activate(Config cfg) {
              // should be invoked when activating
          }
      
      } 

       

       

      Attachments

        Issue Links

          Activity

            People

              enorman Eric Norman
              enorman Eric Norman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: