Refactor usages of deprecated methods (#18092)

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
pull/18103/head
mlobstein 2025-01-12 15:37:41 -06:00 committed by GitHub
parent fad9107a20
commit 22d907ffb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import static org.openhab.binding.oppo.internal.OppoBindingConstants.*;
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 @@ public class OppoDiscoveryService extends AbstractDiscoveryService {
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 @@ public class OppoDiscoveryService extends AbstractDiscoveryService {
}
}
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);
}
}
});