From b9badc3856dd39a71f548a7a99c2f021e288d6a9 Mon Sep 17 00:00:00 2001 From: Michael Lobstein Date: Sat, 11 Jan 2025 11:24:41 -0600 Subject: [PATCH] Refactor usages of deprecated methods Signed-off-by: Michael Lobstein --- .../oppo/internal/discovery/OppoDiscoveryService.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/discovery/OppoDiscoveryService.java b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/discovery/OppoDiscoveryService.java index 306c6400fe1b9..a52bebd55e615 100644 --- a/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/discovery/OppoDiscoveryService.java +++ b/bundles/org.openhab.binding.oppo/src/main/java/org/openhab/binding/oppo/internal/discovery/OppoDiscoveryService.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.net.DatagramPacket; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.MulticastSocket; import java.net.NetworkInterface; import java.net.SocketTimeoutException; @@ -138,9 +139,10 @@ protected void startScan() { service.execute(() -> { try { MulticastSocket multiSocket = new MulticastSocket(SDDP_PORT); + InetSocketAddress inetSocketAddress = new InetSocketAddress(addr, SDDP_PORT); multiSocket.setSoTimeout(TIMEOUT_MS); multiSocket.setNetworkInterface(netint); - multiSocket.joinGroup(addr); + multiSocket.joinGroup(inetSocketAddress, null); while (scanning) { DatagramPacket receivePacket = new DatagramPacket(new byte[BUFFER_SIZE], BUFFER_SIZE); @@ -156,10 +158,13 @@ protected void startScan() { } } + multiSocket.leaveGroup(inetSocketAddress, null); multiSocket.close(); } catch (IOException e) { - if (e.getMessage() != null && !e.getMessage().contains("No IP addresses bound to interface")) { - logger.debug("OppoDiscoveryService IOException: {}", e.getMessage(), e); + final String message = e.getMessage(); + if (message != null && !message.contains("No IP addresses bound to interface") + && !message.contains("Network interface not configured for IPv4")) { + logger.debug("OppoDiscoveryService IOException: {}", message, e); } } });