Fix for NPE when getting network interface name (#14603)
Signed-off-by: Mark Hilbush <mark@hilbush.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -105,8 +105,9 @@ public class GlobalCacheHandler extends BaseThingHandler {
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user