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

HealthCheckMetadata wrongly assumes (String) SERVICE_PID

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • Health Check Core 1.2.4
    • Health Check Core 1.2.6
    • Health Check
    • None

    Description

      I'm getting a classcastexception in the healthcheck component. This is happenning only for my components (don't know why :-S).

      I have looked at the source code and in my case at the AsyncHelthCheckExecutor the code passes the lines bellow

      AsyncHelthCheckExecutor.java
      ServiceReference serviceReference = event.getServiceReference();
              final boolean isHealthCheck = serviceReference.isAssignableTo(bundleContext.getBundle(), HealthCheck.class.getName());
      
              if (isHealthCheck) {
                  // True at my case
              }
      

      Later in the method getHealthCheckTitle of the class HealthCheckMetadata at the line bellow:

      HealthCheckMetadata.java
       if (StringUtils.isBlank(name)) {
                  name = (String) ref.getProperty(Constants.SERVICE_PID);
              }
      

      ref.getProperty(Constants.SERVICE_PID) is returning an ArrayList and I have the stacktrace bellow as a result

      Stacktrace
      java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
      	at org.apache.sling.hc.util.HealthCheckMetadata.getHealthCheckTitle(HealthCheckMetadata.java:146)
      	at org.apache.sling.hc.util.HealthCheckMetadata.<init>(HealthCheckMetadata.java:53)
      	at org.apache.sling.hc.core.impl.executor.AsyncHealthCheckExecutor.serviceChanged(AsyncHealthCheckExecutor.java:114)
      	at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:991)
      	at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:839)
      	at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:546)
      	at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4557)
      	at org.apache.felix.framework.Felix.registerService(Felix.java:3549)
      	at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857)
      	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:399)
      	at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:676)
      	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339)
      	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:360)
      	at org.apache.felix.scr.impl.Activator.access$000(Activator.java:53)
      	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:260)
      	at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
      	at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
      	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482)
      	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415)
      	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
      	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
      	at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:916)
      	at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:835)
      	at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:517)
      	at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541)
      	at org.apache.felix.framework.Felix.startBundle(Felix.java:2172)
      	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
      	at aQute.launcher.Launcher.update(Launcher.java:482)
      	at aQute.launcher.Launcher.activate(Launcher.java:381)
      	at aQute.launcher.Launcher.run(Launcher.java:275)
      	at aQute.launcher.Launcher.main(Launcher.java:132)
      

      Attachments

        Issue Links

          Activity

            People

              bdelacretaz Bertrand Delacretaz
              ivoleitao Ivo Leitão
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: