mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-11 05:41:52 +01:00
Fix potential NPE in ProfileCallbackImpl (#1627)
Also annotates ItemChannelLink. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
02404b2fa7
commit
2273f8976f
@ -137,6 +137,12 @@ public class ProfileCallbackImpl implements ProfileCallback {
|
||||
@Override
|
||||
public void sendUpdate(State state) {
|
||||
Item item = itemProvider.apply(link.getItemName());
|
||||
if (item == null) {
|
||||
logger.warn("Cannot post update event '{}' for item '{}', because no item could be found.", state,
|
||||
link.getItemName());
|
||||
return;
|
||||
}
|
||||
|
||||
State acceptedState;
|
||||
if (state instanceof StringType && !(item instanceof StringItem)) {
|
||||
acceptedState = TypeParser.parseState(item.getAcceptedDataTypes(), state.toString());
|
||||
@ -146,6 +152,7 @@ public class ProfileCallbackImpl implements ProfileCallback {
|
||||
} else {
|
||||
acceptedState = itemStateConverter.convertToAcceptedState(state, item);
|
||||
}
|
||||
|
||||
eventPublisher.post(
|
||||
ItemEventFactory.createStateEvent(link.getItemName(), acceptedState, link.getLinkedUID().toString()));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
package org.openhab.core.thing.link;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
import org.openhab.core.items.Item;
|
||||
import org.openhab.core.thing.ChannelUID;
|
||||
@ -23,9 +24,10 @@ import org.openhab.core.thing.ChannelUID;
|
||||
* @author Jochen Hiller - Bugfix 455434: added default constructor, object is now mutable
|
||||
* @author Simon Kaufmann - added configuration
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class ItemChannelLink extends AbstractLink {
|
||||
|
||||
private final ChannelUID channelUID;
|
||||
private final @NonNullByDefault({}) ChannelUID channelUID;
|
||||
private final Configuration configuration;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user