openhab-core: [thing actions] Actions fail to execute after a binding restart

Reference my comment here.

Most (if not all) thing action implementations contain code that looks like this.

    public static void restart(@Nullable ThingActions actions) {
        if (actions instanceof DoorbirdActions) {
            ((DoorbirdActions) actions).restart();
        } else {
            throw new IllegalArgumentException("Instance is not a DoorbirdActionsService class");
        }
    }

Normally, the instanceof test succeeds. However, after installing a new version of the binding, this test fails, which causes the code to throw IllegalArgumentException when invoking the action from a rule. This condition can only be cleared by restarting openHAB. There are several ways to reproduce this, one of which is to drop a new version of a binding into addons that overwrites an older version that’s already there.

After installing the new version of the binding, it appears that the classloader instances are different. I suspect this is what’s causing the instanceof test to fail.

Before installing new binding version:

2019-12-09 09:23:02.018 [INFO ] [ding.doorbird.action.DoorbirdActions] - DoorbirdActions classloader org.eclipse.osgi.internal.loader.EquinoxClassLoader@50578098[org.openhab.binding.doorbird:2.5.0.201912091420(id=245)]
2019-12-09 09:23:02.019 [INFO ] [ding.doorbird.action.DoorbirdActions] - ThingActions actions classloader org.eclipse.osgi.internal.loader.EquinoxClassLoader@50578098[org.openhab.binding.doorbird:2.5.0.201912091420(id=245)]

After installing new binding version:

2019-12-09 09:24:39.813 [INFO ] [ding.doorbird.action.DoorbirdActions] - DoorbirdActions classloader org.eclipse.osgi.internal.loader.EquinoxClassLoader@50578098[org.openhab.binding.doorbird:2.5.0.201912091423(id=245)]
2019-12-09 09:24:39.814 [INFO ] [ding.doorbird.action.DoorbirdActions] - ThingActions actions classloader org.eclipse.osgi.internal.loader.EquinoxClassLoader@1c14e241[org.openhab.binding.doorbird:2.5.0.201912091423(id=245)]

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 33 (33 by maintainers)

Commits related to this issue

Most upvoted comments

How many? At least 9. That is a lot when you face of such issue.

What is blocking us from making a bug fix release for core? These ugly workarounds are lots of work and also are not very inviting to add more thing actions to current bindings?

The good news is that so far I’ve not been able to replicate the issue using the NGRE.