diff --git a/bundles/org.openhab.binding.benqprojector/src/main/java/org/openhab/binding/benqprojector/internal/discovery/MulticastListener.java b/bundles/org.openhab.binding.benqprojector/src/main/java/org/openhab/binding/benqprojector/internal/discovery/MulticastListener.java index f00d5ee1b5762..92e24ee0d6bfd 100644 --- a/bundles/org.openhab.binding.benqprojector/src/main/java/org/openhab/binding/benqprojector/internal/discovery/MulticastListener.java +++ b/bundles/org.openhab.binding.benqprojector/src/main/java/org/openhab/binding/benqprojector/internal/discovery/MulticastListener.java @@ -12,9 +12,7 @@ */ package org.openhab.binding.benqprojector.internal.discovery; -import static org.openhab.binding.benqprojector.internal.BenqProjectorBindingConstants.DEFAULT_PORT; -import static org.openhab.binding.benqprojector.internal.BenqProjectorBindingConstants.THING_PROPERTY_HOST; -import static org.openhab.binding.benqprojector.internal.BenqProjectorBindingConstants.THING_PROPERTY_PORT; +import static org.openhab.binding.benqprojector.internal.BenqProjectorBindingConstants.*; import java.io.IOException; import java.net.DatagramPacket; @@ -59,8 +57,9 @@ public class MulticastListener { */ public MulticastListener(String ipv4Address) throws IOException, SocketException { InetAddress ifAddress = InetAddress.getByName(ipv4Address); + NetworkInterface netIF = NetworkInterface.getByInetAddress(ifAddress); logger.debug("Discovery job using address {} on network interface {}", ifAddress.getHostAddress(), - NetworkInterface.getByInetAddress(ifAddress).getName()); + netIF != null ? netIF.getName() : "UNKNOWN"); socket = new MulticastSocket(AMX_MULTICAST_PORT); socket.setInterface(ifAddress); socket.setSoTimeout(DEFAULT_SOCKET_TIMEOUT_SEC); diff --git a/bundles/org.openhab.binding.bigassfan/src/main/java/org/openhab/binding/bigassfan/internal/handler/BigAssFanHandler.java b/bundles/org.openhab.binding.bigassfan/src/main/java/org/openhab/binding/bigassfan/internal/handler/BigAssFanHandler.java index 1ef3fd374cfdc..1430b34109897 100644 --- a/bundles/org.openhab.binding.bigassfan/src/main/java/org/openhab/binding/bigassfan/internal/handler/BigAssFanHandler.java +++ b/bundles/org.openhab.binding.bigassfan/src/main/java/org/openhab/binding/bigassfan/internal/handler/BigAssFanHandler.java @@ -1024,9 +1024,9 @@ public ConnectionManager(@Nullable String ipv4Address) { deviceIsConnected = false; try { ifAddress = InetAddress.getByName(ipv4Address); - + NetworkInterface netIF = NetworkInterface.getByInetAddress(ifAddress); logger.debug("Handler for {} using address {} on network interface {}", thing.getUID(), ipv4Address, - NetworkInterface.getByInetAddress(ifAddress).getName()); + netIF != null ? netIF.getName() : "UNKNOWN"); } catch (UnknownHostException e) { logger.warn("Handler for {} got UnknownHostException getting local IPv4 net interface: {}", thing.getUID(), e.getMessage(), e); diff --git a/bundles/org.openhab.binding.epsonprojector/src/main/java/org/openhab/binding/epsonprojector/internal/discovery/MulticastListener.java b/bundles/org.openhab.binding.epsonprojector/src/main/java/org/openhab/binding/epsonprojector/internal/discovery/MulticastListener.java index b7f3be2f2e1a5..44ff739514489 100644 --- a/bundles/org.openhab.binding.epsonprojector/src/main/java/org/openhab/binding/epsonprojector/internal/discovery/MulticastListener.java +++ b/bundles/org.openhab.binding.epsonprojector/src/main/java/org/openhab/binding/epsonprojector/internal/discovery/MulticastListener.java @@ -12,9 +12,7 @@ */ package org.openhab.binding.epsonprojector.internal.discovery; -import static org.openhab.binding.epsonprojector.internal.EpsonProjectorBindingConstants.DEFAULT_PORT; -import static org.openhab.binding.epsonprojector.internal.EpsonProjectorBindingConstants.THING_PROPERTY_HOST; -import static org.openhab.binding.epsonprojector.internal.EpsonProjectorBindingConstants.THING_PROPERTY_PORT; +import static org.openhab.binding.epsonprojector.internal.EpsonProjectorBindingConstants.*; import java.io.IOException; import java.net.DatagramPacket; @@ -59,8 +57,9 @@ public class MulticastListener { */ public MulticastListener(String ipv4Address) throws IOException, SocketException { InetAddress ifAddress = InetAddress.getByName(ipv4Address); + NetworkInterface netIF = NetworkInterface.getByInetAddress(ifAddress); logger.debug("Discovery job using address {} on network interface {}", ifAddress.getHostAddress(), - NetworkInterface.getByInetAddress(ifAddress).getName()); + netIF != null ? netIF.getName() : "UNKNOWN"); socket = new MulticastSocket(AMX_MULTICAST_PORT); socket.setInterface(ifAddress); socket.setSoTimeout(DEFAULT_SOCKET_TIMEOUT_SEC); diff --git a/bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/discovery/MulticastListener.java b/bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/discovery/MulticastListener.java index 3819fdca8317b..17c9312c114af 100644 --- a/bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/discovery/MulticastListener.java +++ b/bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/discovery/MulticastListener.java @@ -63,8 +63,9 @@ public class MulticastListener { */ public MulticastListener(String ipv4Address) throws IOException, SocketException { InetAddress ifAddress = InetAddress.getByName(ipv4Address); + NetworkInterface netIF = NetworkInterface.getByInetAddress(ifAddress); logger.debug("Discovery job using address {} on network interface {}", ifAddress.getHostAddress(), - NetworkInterface.getByInetAddress(ifAddress).getName()); + netIF != null ? netIF.getName() : "UNKNOWN"); socket = new MulticastSocket(GC_MULTICAST_PORT); socket.setInterface(ifAddress); socket.setSoTimeout(DEFAULT_SOCKET_TIMEOUT); diff --git a/bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/handler/GlobalCacheHandler.java b/bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/handler/GlobalCacheHandler.java index 9456d28227f51..a56c65c3946b9 100644 --- a/bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/handler/GlobalCacheHandler.java +++ b/bundles/org.openhab.binding.globalcache/src/main/java/org/openhab/binding/globalcache/internal/handler/GlobalCacheHandler.java @@ -105,8 +105,9 @@ public void initialize() { logger.debug("Initializing thing {}", thingID()); try { ifAddress = InetAddress.getByName(ipv4Address); + NetworkInterface netIF = NetworkInterface.getByInetAddress(ifAddress); logger.debug("Handler using address {} on network interface {}", ifAddress.getHostAddress(), - NetworkInterface.getByInetAddress(ifAddress).getName()); + netIF != null ? netIF.getName() : "UNKNOWN"); } catch (SocketException e) { logger.error("Handler got Socket exception creating multicast socket: {}", e.getMessage()); markThingOfflineWithError(ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "No suitable network interface");