import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.config.discovery.DiscoveryService;
*
* @author Mark Hilbush - Initial contribution
*/
+@NonNullByDefault
@Component(service = DiscoveryService.class, configurationPid = "discovery.bigassfan")
public class BigAssFanDiscoveryService extends AbstractDiscoveryService {
private final Logger logger = LoggerFactory.getLogger(BigAssFanDiscoveryService.class);
// Our own thread pool for the long-running listener job
private ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
- private ScheduledFuture<?> listenerJob;
-
- DiscoveryListener discoveryListener;
-
+ private @Nullable ScheduledFuture<?> listenerJob;
+ private @Nullable DiscoveryListener discoveryListener;
private boolean terminate;
-
private final Pattern announcementPattern = Pattern.compile("[(](.*);DEVICE;ID;(.*);(.*)[)]");
private Runnable listenerRunnable = () -> {
};
// Frequency (in seconds) with which we poll for new devices
- private final long POLL_FREQ = 300L;
- private final long POLL_DELAY = 12L;
- private ScheduledFuture<?> pollJob;
+ private static final long POLL_FREQ = 300L;
+ private static final long POLL_DELAY = 12L;
+ private @Nullable ScheduledFuture<?> pollJob;
public BigAssFanDiscoveryService() {
super(SUPPORTED_THING_TYPES_UIDS, 0, BACKGROUND_DISCOVERY_ENABLED);
}
@Override
- protected void activate(Map<String, Object> configProperties) {
+ protected void activate(@Nullable Map<String, Object> configProperties) {
super.activate(configProperties);
logger.trace("BigAssFan discovery service ACTIVATED");
}
@Override
@Modified
- protected void modified(Map<String, Object> configProperties) {
+ protected void modified(@Nullable Map<String, Object> configProperties) {
super.modified(configProperties);
}
cancelListenerJob();
}
- private void startListenerJob() {
- if (listenerJob == null) {
- terminate = false;
+ private synchronized void startListenerJob() {
+ if (this.listenerJob == null) {
logger.debug("Starting discovery listener job in {} seconds", BACKGROUND_DISCOVERY_DELAY);
- listenerJob = scheduledExecutorService.schedule(listenerRunnable, BACKGROUND_DISCOVERY_DELAY,
+ terminate = false;
+ this.listenerJob = scheduledExecutorService.schedule(listenerRunnable, BACKGROUND_DISCOVERY_DELAY,
TimeUnit.SECONDS);
}
}
private void cancelListenerJob() {
- if (listenerJob != null) {
+ ScheduledFuture<?> localListenerJob = this.listenerJob;
+ if (localListenerJob != null) {
logger.debug("Canceling discovery listener job");
- listenerJob.cancel(true);
+ localListenerJob.cancel(true);
terminate = true;
- listenerJob = null;
+ this.listenerJob = null;
}
}
private synchronized void listen() {
logger.info("BigAssFan discovery service is running");
+ DiscoveryListener localDiscoveryListener;
try {
- discoveryListener = new DiscoveryListener();
+ localDiscoveryListener = new DiscoveryListener();
+ discoveryListener = localDiscoveryListener;
} catch (SocketException se) {
logger.warn("Got Socket exception creating multicast socket: {}", se.getMessage(), se);
return;
while (!terminate) {
try {
// Wait for a discovery message
- processMessage(discoveryListener.waitForMessage());
+ processMessage(localDiscoveryListener.waitForMessage());
} catch (SocketTimeoutException e) {
// Read on socket timed out; check for termination
continue;
break;
}
}
- discoveryListener.shutdown();
+ localDiscoveryListener.shutdown();
logger.debug("DiscoveryListener job is exiting");
}
private void processMessage(BigAssFanDevice device) {
- if (device == null) {
- return;
- }
Matcher matcher = announcementPattern.matcher(device.getDiscoveryMessage());
if (matcher.find()) {
logger.debug("Match: grp1={}, grp2={}, grp(3)={}", matcher.group(1), matcher.group(2), matcher.group(3));
.withRepresentationProperty(THING_PROPERTY_MAC).withLabel(device.getLabel()).build());
}
- private void schedulePollJob() {
- logger.debug("Scheduling discovery poll job to run every {} seconds starting in {} sec", POLL_FREQ, POLL_DELAY);
+ private synchronized void schedulePollJob() {
cancelPollJob();
- pollJob = scheduler.scheduleWithFixedDelay(() -> {
- try {
- discoveryListener.pollForDevices();
- } catch (RuntimeException e) {
- logger.warn("Poll job got unexpected exception: {}", e.getMessage(), e);
- }
- }, POLL_DELAY, POLL_FREQ, TimeUnit.SECONDS);
+ if (this.pollJob == null) {
+ logger.debug("Scheduling discovery poll job to run every {} seconds starting in {} sec", POLL_FREQ,
+ POLL_DELAY);
+ pollJob = scheduler.scheduleWithFixedDelay(() -> {
+ try {
+ DiscoveryListener localListener = discoveryListener;
+ if (localListener != null) {
+ localListener.pollForDevices();
+ }
+ } catch (RuntimeException e) {
+ logger.warn("Poll job got unexpected exception: {}", e.getMessage(), e);
+ }
+ }, POLL_DELAY, POLL_FREQ, TimeUnit.SECONDS);
+ }
}
private void cancelPollJob() {
- if (pollJob != null) {
+ ScheduledFuture<?> localPollJob = pollJob;
+ if (localPollJob != null) {
logger.debug("Canceling poll job");
- pollJob.cancel(true);
- pollJob = null;
+ localPollJob.cancel(true);
+ this.pollJob = null;
}
}
}
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*
* @author Mark Hilbush - Initial contribution
*/
+@NonNullByDefault
public class DiscoveryListener {
private final Logger logger = LoggerFactory.getLogger(DiscoveryListener.class);
- private final String BCAST_ADDRESS = "255.255.255.255";
- private final int SOCKET_RECEIVE_TIMEOUT = 500;
-
- private final String POLL_MESSAGE = "<ALL;DEVICE;ID;GET>";
+ private static final String BCAST_ADDRESS = "255.255.255.255";
+ private static final int SOCKET_RECEIVE_TIMEOUT = 500;
+ private static final String POLL_MESSAGE = "<ALL;DEVICE;ID;GET>";
+ @Nullable
DatagramSocket dSocket;
+ @Nullable
DatagramPacket rcvPacket;
- byte[] rcvBuffer;
+ byte[] rcvBuffer = new byte[0];
+ @Nullable
InetAddress bcastAddress;
- byte[] bcastBuffer;
+ byte[] bcastBuffer = new byte[0];
+ @Nullable
DatagramPacket bcastPacket;
BigAssFanDevice device;
device = new BigAssFanDevice();
try {
// Create a socket on the UDP port and get send & receive buffers
- dSocket = new DatagramSocket(BAF_PORT);
- dSocket.setSoTimeout(SOCKET_RECEIVE_TIMEOUT);
- dSocket.setBroadcast(true);
+ DatagramSocket localDatagramSocket = new DatagramSocket(BAF_PORT);
+ localDatagramSocket.setSoTimeout(SOCKET_RECEIVE_TIMEOUT);
+ localDatagramSocket.setBroadcast(true);
+ dSocket = localDatagramSocket;
rcvBuffer = new byte[256];
rcvPacket = new DatagramPacket(rcvBuffer, rcvBuffer.length);
bcastAddress = InetAddress.getByName(BCAST_ADDRESS);
bcastBuffer = POLL_MESSAGE.getBytes(StandardCharsets.US_ASCII);
bcastPacket = new DatagramPacket(bcastBuffer, bcastBuffer.length, bcastAddress, BAF_PORT);
- } catch (UnknownHostException uhe) {
- logger.warn("UnknownHostException sending poll request for fans: {}", uhe.getMessage(), uhe);
+ } catch (UnknownHostException | SocketException | SecurityException e) {
+ logger.warn("Unexpected exception sending poll request for fans: {}", e.getMessage(), e);
}
}
public BigAssFanDevice waitForMessage() throws IOException, SocketTimeoutException {
// Wait to receive a packet
- rcvPacket.setLength(rcvBuffer.length);
- dSocket.receive(rcvPacket);
+ DatagramPacket localPacket = rcvPacket;
+ DatagramSocket localDatagramSocket = dSocket;
+
+ if (localPacket != null) {
+ localPacket.setLength(rcvBuffer.length);
+ }
+
+ if (localDatagramSocket != null && localPacket != null) {
+ localDatagramSocket.receive(localPacket);
- // Process the received packet
- device.reset();
- device.setIpAddress(rcvPacket.getAddress().getHostAddress());
- String message = (new String(rcvBuffer, 0, rcvPacket.getLength()));
- device.setDiscoveryMessage(message);
- logger.debug("RECEIVED packet of length {} from {}: {}", message.length(), device.getIpAddress(), message);
+ // Process the received packet
+ device.reset();
+
+ String address = localPacket.getAddress().getHostAddress();
+ device.setIpAddress(address != null ? address : "");
+
+ String message = (new String(rcvBuffer, 0, localPacket.getLength()));
+ device.setDiscoveryMessage(message);
+ logger.debug("RECEIVED packet of length {} from {}: {}", message.length(), device.getIpAddress(), message);
+ }
return device;
}
public void pollForDevices() {
- if (dSocket == null) {
+ DatagramSocket localDatagramSocket = dSocket;
+ if (localDatagramSocket == null) {
logger.debug("Socket is null in discoveryListener.pollForDevices()");
return;
}
logger.debug("Sending poll request for fans: {}", POLL_MESSAGE);
try {
- dSocket.send(bcastPacket);
- } catch (IOException ioe) {
- logger.warn("IOException sending poll request for fans: {}", ioe.getMessage(), ioe);
+ localDatagramSocket.send(bcastPacket);
+ } catch (IllegalArgumentException | SecurityException | IOException e) {
+ logger.warn("Unexpected exception while sending poll request for fans: {}", e.getMessage(), e);
}
}
public void shutdown() {
logger.debug("DiscoveryListener closing socket");
- if (dSocket != null) {
- dSocket.close();
+ DatagramSocket localDatagramSocket = dSocket;
+ if (localDatagramSocket != null) {
+ localDatagramSocket.close();
dSocket = null;
}
}
import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.BufferOverflowException;
+import java.nio.channels.IllegalBlockingModeException;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.ZoneId;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.bigassfan.internal.BigAssFanConfig;
import org.openhab.binding.bigassfan.internal.utils.BigAssFanConverter;
import org.openhab.core.common.ThreadPoolManager;
*
* @author Mark Hilbush - Initial contribution
*/
+@NonNullByDefault
public class BigAssFanHandler extends BaseThingHandler {
private final Logger logger = LoggerFactory.getLogger(BigAssFanHandler.class);
private static final StringType COOLING = new StringType("COOLING");
private static final StringType HEATING = new StringType("HEATING");
- private BigAssFanConfig config;
- private String label = null;
- private String ipAddress = null;
- private String macAddress = null;
+ private String label = "";
+ private String ipAddress = "";
+ private String macAddress = "";
- private FanListener fanListener;
+ private final FanListener fanListener;
- protected Map<String, State> fanStateMap = Collections.synchronizedMap(new HashMap<>());
+ protected final Map<String, State> fanStateMap = Collections.synchronizedMap(new HashMap<>());
- public BigAssFanHandler(Thing thing, String ipv4Address) {
+ public BigAssFanHandler(Thing thing, @Nullable String ipv4Address) {
super(thing);
this.thing = thing;
public void initialize() {
logger.debug("BigAssFanHandler for {} is initializing", thing.getUID());
- config = getConfig().as(BigAssFanConfig.class);
- logger.debug("BigAssFanHandler config for {} is {}", thing.getUID(), config);
+ BigAssFanConfig configuration = getConfig().as(BigAssFanConfig.class);
+ logger.debug("BigAssFanHandler config for {} is {}", thing.getUID(), configuration);
- if (!config.isValid()) {
+ if (!configuration.isValid()) {
logger.debug("BigAssFanHandler config of {} is invalid. Check configuration", thing.getUID());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Invalid BigAssFan config. Check configuration.");
return;
}
- label = config.getLabel();
- ipAddress = config.getIpAddress();
- macAddress = config.getMacAddress();
+
+ label = configuration.getLabel();
+ ipAddress = configuration.getIpAddress();
+ macAddress = configuration.getMacAddress();
fanListener.startFanListener();
}
private void adjustMaxSpeed(PercentType command, String channelId, String commandFragment) {
int newMin = command.intValue();
int currentMax = PercentType.ZERO.intValue();
- if (fanStateMap.get(channelId) != null) {
- currentMax = ((PercentType) fanStateMap.get(channelId)).intValue();
+ State fanState = fanStateMap.get(channelId);
+ if (fanState != null) {
+ currentMax = ((PercentType) fanState).intValue();
}
if (newMin > currentMax) {
updateState(CHANNEL_FAN_SPEED_MAX, command);
private void adjustMinSpeed(PercentType command, String channelId, String commandFragment) {
int newMax = command.intValue();
int currentMin = PercentType.HUNDRED.intValue();
- if (fanStateMap.get(channelId) != null) {
- currentMin = ((PercentType) fanStateMap.get(channelId)).intValue();
+ State fanSate = fanStateMap.get(channelId);
+ if (fanSate != null) {
+ currentMin = ((PercentType) fanSate).intValue();
}
if (newMax < currentMin) {
updateState(channelId, command);
private void adjustMaxLevel(PercentType command) {
int newMin = command.intValue();
int currentMax = PercentType.ZERO.intValue();
- if (fanStateMap.get(CHANNEL_LIGHT_LEVEL_MAX) != null) {
- currentMax = ((PercentType) fanStateMap.get(CHANNEL_LIGHT_LEVEL_MAX)).intValue();
+ State fanState = fanStateMap.get(CHANNEL_LIGHT_LEVEL_MAX);
+ if (fanState != null) {
+ currentMax = ((PercentType) fanState).intValue();
}
if (newMin > currentMax) {
updateState(CHANNEL_LIGHT_LEVEL_MAX, command);
private void adjustMinLevel(PercentType command) {
int newMax = command.intValue();
int currentMin = PercentType.HUNDRED.intValue();
- if (fanStateMap.get(CHANNEL_LIGHT_LEVEL_MIN) != null) {
- currentMin = ((PercentType) fanStateMap.get(CHANNEL_LIGHT_LEVEL_MIN)).intValue();
+ State fanState = fanStateMap.get(CHANNEL_LIGHT_LEVEL_MIN);
+ if (fanState != null) {
+ currentMin = ((PercentType) fanState).intValue();
}
if (newMax < currentMin) {
updateState(CHANNEL_LIGHT_LEVEL_MIN, command);
* Send a command to the fan
*/
private void sendCommand(String mac, String commandFragment) {
- if (fanListener == null) {
- logger.error("Unable to send message to {} because fanListener object is null!", thing.getUID());
- return;
- }
-
StringBuilder sb = new StringBuilder();
sb.append("<").append(mac).append(commandFragment).append(">");
String message = sb.toString();
}
}
- private void markOfflineWithMessage(ThingStatusDetail statusDetail, String statusMessage) {
+ private void markOfflineWithMessage(ThingStatusDetail statusDetail, @Nullable String statusMessage) {
// If it's offline with no detail or if it's not offline, mark it offline with detailed status
if ((isOffline() && getDetail() == ThingStatusDetail.NONE) || !isOffline()) {
logger.debug("Changing status of {} from {}({}) to OFFLINE({})", thing.getUID(), getStatus(), getDetail(),
// Our own thread pool for the long-running listener job
private ScheduledExecutorService scheduledExecutorService = ThreadPoolManager
.getScheduledPool("bigassfanHandler" + "-" + thing.getUID());
- private ScheduledFuture<?> listenerJob;
+ private @Nullable ScheduledFuture<?> listenerJob;
- private final long FAN_LISTENER_DELAY = 2L;
+ private static final long FAN_LISTENER_DELAY = 2L;
private boolean terminate;
private final Pattern messagePattern = Pattern.compile("[(](.*)");
}
};
- public FanListener(String ipv4Address) {
+ public FanListener(@Nullable String ipv4Address) {
conn = new ConnectionManager(ipv4Address);
}
}
public void stopFanListener() {
- if (listenerJob != null) {
+ ScheduledFuture<?> localListenerJob = listenerJob;
+ if (localListenerJob != null) {
logger.debug("Stopping listener for {} at {}", thing.getUID(), ipAddress);
terminate = true;
- listenerJob.cancel(true);
- listenerJob = null;
+ localListenerJob.cancel(true);
+ this.listenerJob = null;
}
+
conn.cancelConnectionMonitorJob();
conn.disconnect();
}
logger.debug("Fan listener thread is exiting for {} at {}", thing.getUID(), ipAddress);
}
- private String waitForMessage() throws IOException {
+ private @Nullable String waitForMessage() throws IOException {
if (!conn.isConnected()) {
if (logger.isTraceEnabled()) {
logger.trace("FanListener for {} can't receive message. No connection to fan", thing.getUID());
return readMessage();
}
- private String readMessage() {
+ private @Nullable String readMessage() {
logger.trace("Waiting for message from {} at {}", thing.getUID(), ipAddress);
String message = conn.read();
if (message != null) {
return message;
}
- private void processMessage(String incomingMessage) {
+ private void processMessage(@Nullable String incomingMessage) {
if (incomingMessage == null || incomingMessage.isEmpty()) {
return;
}
return true;
}
// Didn't match MAC address, check match for label
- if (label.equalsIgnoreCase(idFromDevice)) {
- return true;
- }
- return false;
+ return label.equalsIgnoreCase(idFromDevice);
}
private void updateFanPower(String[] messageParts) {
private boolean deviceIsConnected;
- private InetAddress ifAddress;
- private Socket fanSocket;
- private Scanner fanScanner;
- private DataOutputStream fanWriter;
- private final int SOCKET_CONNECT_TIMEOUT = 1500;
+ private @Nullable InetAddress ifAddress;
+ private @Nullable Socket fanSocket;
+ private @Nullable Scanner fanScanner;
+ private @Nullable DataOutputStream fanWriter;
+ private static final int SOCKET_CONNECT_TIMEOUT = 1500;
- ScheduledFuture<?> connectionMonitorJob;
- private final long CONNECTION_MONITOR_FREQ = 120L;
- private final long CONNECTION_MONITOR_DELAY = 30L;
+ private @Nullable ScheduledFuture<?> connectionMonitorJob;
+ private static final long CONNECTION_MONITOR_FREQ = 120L;
+ private static final long CONNECTION_MONITOR_DELAY = 30L;
Runnable connectionMonitorRunnable = () -> {
logger.trace("Performing connection check for {} at IP {}", thing.getUID(), ipAddress);
checkConnection();
};
- public ConnectionManager(String ipv4Address) {
+ public ConnectionManager(@Nullable String ipv4Address) {
deviceIsConnected = false;
try {
ifAddress = InetAddress.getByName(ipv4Address);
- logger.debug("Handler for {} using address {} on network interface {}", thing.getUID(),
- ifAddress.getHostAddress(), NetworkInterface.getByInetAddress(ifAddress).getName());
+
+ logger.debug("Handler for {} using address {} on network interface {}", thing.getUID(), ipv4Address,
+ NetworkInterface.getByInetAddress(ifAddress).getName());
} catch (UnknownHostException e) {
logger.warn("Handler for {} got UnknownHostException getting local IPv4 net interface: {}",
thing.getUID(), e.getMessage(), e);
}
logger.trace("Connecting to {} at {}", thing.getUID(), ipAddress);
+ Socket localFanSocket = new Socket();
+ fanSocket = localFanSocket;
// Open socket
try {
- fanSocket = new Socket();
- fanSocket.bind(new InetSocketAddress(ifAddress, 0));
- fanSocket.connect(new InetSocketAddress(ipAddress, BAF_PORT), SOCKET_CONNECT_TIMEOUT);
- } catch (IOException e) {
- logger.debug("IOException connecting to {} at {}: {}", thing.getUID(), ipAddress, e.getMessage());
+ localFanSocket.bind(new InetSocketAddress(ifAddress, 0));
+ localFanSocket.connect(new InetSocketAddress(ipAddress, BAF_PORT), SOCKET_CONNECT_TIMEOUT);
+ } catch (SecurityException | IllegalArgumentException | IOException e) {
+ logger.debug("Unexpected exception connecting to {} at {}: {}", thing.getUID(), ipAddress,
+ e.getMessage(), e);
markOfflineWithMessage(ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, e.getMessage());
disconnect();
return;
// Create streams
try {
- fanWriter = new DataOutputStream(fanSocket.getOutputStream());
- fanScanner = new Scanner(fanSocket.getInputStream());
- fanScanner.useDelimiter("[)]");
- } catch (IOException e) {
- logger.warn("IOException getting streams for {} at {}: {}", thing.getUID(), ipAddress, e.getMessage(),
- e);
+ fanWriter = new DataOutputStream(localFanSocket.getOutputStream());
+ Scanner localFanScanner = new Scanner(localFanSocket.getInputStream());
+ localFanScanner.useDelimiter("[)]");
+ fanScanner = localFanScanner;
+ } catch (IllegalBlockingModeException | IOException e) {
+ logger.warn("Exception getting streams for {} at {}: {}", thing.getUID(), ipAddress, e.getMessage(), e);
markOfflineWithMessage(ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, e.getMessage());
disconnect();
return;
logger.debug("Disconnecting from {} at {}", thing.getUID(), ipAddress);
try {
- if (fanWriter != null) {
- fanWriter.close();
+ DataOutputStream localFanWriter = fanWriter;
+ if (localFanWriter != null) {
+ localFanWriter.close();
+ fanWriter = null;
}
- if (fanScanner != null) {
- fanScanner.close();
+ Scanner localFanScanner = fanScanner;
+ if (localFanScanner != null) {
+ localFanScanner.close();
}
- if (fanSocket != null) {
- fanSocket.close();
+ Socket localFanSocket = fanSocket;
+ if (localFanSocket != null) {
+ localFanSocket.close();
+ fanSocket = null;
}
- } catch (IOException e) {
- logger.warn("IOException closing connection to {} at {}: {}", thing.getUID(), ipAddress, e.getMessage(),
+ } catch (IllegalStateException | IOException e) {
+ logger.warn("Exception closing connection to {} at {}: {}", thing.getUID(), ipAddress, e.getMessage(),
e);
}
deviceIsConnected = false;
markOffline();
}
- public String read() {
+ public @Nullable String read() {
if (fanScanner == null) {
logger.warn("Scanner for {} is null when trying to scan from {}!", thing.getUID(), ipAddress);
return null;
}
- String nextToken;
+ String nextToken = null;
try {
- nextToken = fanScanner.next();
+ Scanner localFanScanner = fanScanner;
+ if (localFanScanner != null) {
+ nextToken = localFanScanner.next();
+ }
} catch (NoSuchElementException e) {
logger.debug("Scanner for {} threw NoSuchElementException; stream possibly closed", thing.getUID());
// Force a reconnect to the device
}
public void write(byte[] buffer) throws IOException {
- if (fanWriter == null) {
+ DataOutputStream localFanWriter = fanWriter;
+ if (localFanWriter == null) {
logger.warn("fanWriter for {} is null when trying to write to {}!!!", thing.getUID(), ipAddress);
return;
+ } else {
+ localFanWriter.write(buffer, 0, buffer.length);
}
- fanWriter.write(buffer, 0, buffer.length);
}
private boolean isConnected() {
/*
* Periodically validate the command connection to the device by executing a getversion command.
*/
- private void scheduleConnectionMonitorJob() {
+ private synchronized void scheduleConnectionMonitorJob() {
if (connectionMonitorJob == null) {
logger.debug("Starting connection monitor job in {} seconds for {} at {}", CONNECTION_MONITOR_DELAY,
thing.getUID(), ipAddress);
}
private void cancelConnectionMonitorJob() {
- if (connectionMonitorJob != null) {
+ ScheduledFuture<?> localConnectionMonitorJob = connectionMonitorJob;
+ if (localConnectionMonitorJob != null) {
logger.debug("Canceling connection monitor job for {} at {}", thing.getUID(), ipAddress);
- connectionMonitorJob.cancel(true);
+ localConnectionMonitorJob.cancel(true);
connectionMonitorJob = null;
}
}