eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
866 stars 781 forks source link

NPE in ThingTypeI18nLocalizationService #4152

Closed kaikreuzer closed 7 years ago

kaikreuzer commented 7 years ago

An NPE has been reported here:

29-Aug-2017 09:06:00.745 [ERROR] [ab.binding.zwave.internal.protocol.ZWaveController] - Exception during ZWave thread: Input 2. {}
java.lang.NullPointerException: null
    at org.eclipse.smarthome.core.thing.i18n.ThingTypeI18nLocalizationService.createLocalizedThingType(ThingTypeI18nLocalizationService.java:67) [108:org.eclipse.smarthome.core.thing:0.9.0.201708281632]
    at org.eclipse.smarthome.core.thing.xml.internal.XmlThingTypeProvider.localize(XmlThingTypeProvider.java:128) [109:org.eclipse.smarthome.core.thing.xml:0.9.0.201708281632]
    at org.eclipse.smarthome.core.thing.xml.internal.XmlThingTypeProvider.localize(XmlThingTypeProvider.java:1) [109:org.eclipse.smarthome.core.thing.xml:0.9.0.201708281632]
    at org.eclipse.smarthome.config.xml.AbstractXmlBasedProvider.acquireLocalizedObject(AbstractXmlBasedProvider.java:211) [100:org.eclipse.smarthome.config.xml:0.9.0.201708281632]
    at org.eclipse.smarthome.config.xml.AbstractXmlBasedProvider.getAll(AbstractXmlBasedProvider.java:165) [100:org.eclipse.smarthome.config.xml:0.9.0.201708281632]
    at org.eclipse.smarthome.core.thing.xml.internal.XmlThingTypeProvider.getThingTypes(XmlThingTypeProvider.java:82) [109:org.eclipse.smarthome.core.thing.xml:0.9.0.201708281632]
    at org.eclipse.smarthome.core.thing.type.ThingTypeRegistry.getThingTypes(ThingTypeRegistry.java:48) [108:org.eclipse.smarthome.core.thing:0.9.0.201708281632]
    at org.eclipse.smarthome.core.thing.type.ThingTypeRegistry.getThingTypes(ThingTypeRegistry.java:59) [108:org.eclipse.smarthome.core.thing:0.9.0.201708281632]
    at org.openhab.binding.zwave.internal.ZWaveConfigProvider.initialiseZWaveThings(ZWaveConfigProvider.java:310) [203:org.openhab.binding.zwave:2.2.0.201708281802]
    at org.openhab.binding.zwave.internal.ZWaveConfigProvider.getProductIndex(ZWaveConfigProvider.java:355) [203:org.openhab.binding.zwave:2.2.0.201708281802]
    at org.openhab.binding.zwave.internal.ZWaveConfigProvider.getThingType(ZWaveConfigProvider.java:382) [203:org.openhab.binding.zwave:2.2.0.201708281802]

It looks to me as if no channel type can be resolved, which leads to the NPE. @lolodomo Should we add a safe-guard here? I am not sure, in which situations we can fail to resolve the channel type, but it seems to happen...

lolodomo commented 7 years ago

I will take a look. It seems to happen when initializing z-wave things. As you said it would be interesting to know in which cases the resolv fails.

kaikreuzer commented 7 years ago

According to this comment, it is most likely due to an invalid thing type definition (having channels that are of a non-declared type). So even if it is an error situation, we should harden the code here and not throw an NPE.

mhilbush commented 7 years ago

@kaikreuzer Do you think the root cause of this issue is the same root cause that's causing the REST API calls to fail as described here.

kaikreuzer commented 7 years ago

@mhilbush Yes, very likely as it seems that the REST response simply states that an unexpected NPE has happened.

sihui62 commented 7 years ago

I vote for a "critical bug" label because since #1024 openHAB is not fully usable anymore:

https://community.openhab.org/t/bug-items-category-missing-paperui-error-500-on-build-1029-on-openhabian/33824 https://community.openhab.org/t/oh-2-2-0-snapshots-1025-1028-zwave-npe/33711/40

lolodomo commented 7 years ago

To be closed, my PR fixing it was merged today.

sihui62 commented 7 years ago

my PR fixing it was merged today.

Thx @lolodomo (and all others) for your hard work, appreciate that.

kaikreuzer commented 7 years ago

FTR, the latest openHAB distro 1030 includes this fix.