* [tradfri] fix null pointer exception when sending command to thing that is offline
* [tradfri] changed coapClient from @NinNullByDefault({}) to @Nullable
Signed-off-by: Rob Nielsen <rob.nielsen@yahoo.com>
import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.tradfri.internal.TradfriCoapClient;
import org.openhab.binding.tradfri.internal.model.TradfriBlindData;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
public void handleCommand(ChannelUID channelUID, Command command) {
if (active) {
if (command instanceof RefreshType) {
- logger.debug("Refreshing channel {}", channelUID);
- coapClient.asyncGet(this);
+ TradfriCoapClient coapClient = this.coapClient;
+ if (coapClient != null) {
+ logger.debug("Refreshing channel {}", channelUID);
+ coapClient.asyncGet(this);
+ } else {
+ logger.debug("coapClient is null!");
+ }
return;
}
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.binding.tradfri.internal.TradfriCoapClient;
import org.openhab.binding.tradfri.internal.model.TradfriControllerData;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
public void handleCommand(ChannelUID channelUID, Command command) {
if (active) {
if (command instanceof RefreshType) {
- logger.debug("Refreshing channel {}", channelUID);
- coapClient.asyncGet(this);
+ TradfriCoapClient coapClient = this.coapClient;
+ if (coapClient != null) {
+ logger.debug("Refreshing channel {}", channelUID);
+ coapClient.asyncGet(this);
+ } else {
+ logger.debug("coapClient is null!");
+ }
return;
}
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.binding.tradfri.internal.TradfriCoapClient;
import org.openhab.binding.tradfri.internal.model.TradfriLightData;
import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.IncreaseDecreaseType;
public void handleCommand(ChannelUID channelUID, Command command) {
if (active) {
if (command instanceof RefreshType) {
- logger.debug("Refreshing channel {}", channelUID);
- coapClient.asyncGet(this);
+ TradfriCoapClient coapClient = this.coapClient;
+ if (coapClient != null) {
+ logger.debug("Refreshing channel {}", channelUID);
+ coapClient.asyncGet(this);
+ } else {
+ logger.debug("coapClient is null!");
+ }
return;
}
import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.CHANNEL_POWER;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.tradfri.internal.TradfriCoapClient;
import org.openhab.binding.tradfri.internal.model.TradfriPlugData;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.thing.ChannelUID;
public void handleCommand(ChannelUID channelUID, Command command) {
if (active) {
if (command instanceof RefreshType) {
- logger.debug("Refreshing channel {}", channelUID);
- coapClient.asyncGet(this);
+ TradfriCoapClient coapClient = this.coapClient;
+ if (coapClient != null) {
+ logger.debug("Refreshing channel {}", channelUID);
+ coapClient.asyncGet(this);
+ } else {
+ logger.debug("coapClient is null!");
+ }
return;
}
import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.openhab.binding.tradfri.internal.TradfriCoapClient;
import org.openhab.binding.tradfri.internal.model.TradfriSensorData;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
public void handleCommand(ChannelUID channelUID, Command command) {
if (active) {
if (command instanceof RefreshType) {
- logger.debug("Refreshing channel {}", channelUID);
- coapClient.asyncGet(this);
+ TradfriCoapClient coapClient = this.coapClient;
+ if (coapClient != null) {
+ logger.debug("Refreshing channel {}", channelUID);
+ coapClient.asyncGet(this);
+ } else {
+ logger.debug("coapClient is null!");
+ }
return;
}
// used to check whether we have already been disposed when receiving data asynchronously
protected volatile boolean active;
- protected @NonNullByDefault({}) TradfriCoapClient coapClient;
+ protected @Nullable TradfriCoapClient coapClient;
private @Nullable CoapObserveRelation observeRelation;
}
protected void set(String payload) {
- logger.debug("Sending payload: {}", payload);
- coapClient.asyncPut(payload, this, scheduler);
+ TradfriCoapClient coapClient = this.coapClient;
+ if (coapClient != null) {
+ logger.debug("Sending payload: {}", payload);
+ coapClient.asyncPut(payload, this, scheduler);
+ } else {
+ logger.debug("coapClient is null!");
+ }
}
protected void updateDeviceProperties(TradfriDeviceData state) {