Skip to content

Commit

Permalink
Refactor usages of deprecated methods (#18092)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Lobstein <[email protected]>
  • Loading branch information
mlobstein authored Jan 12, 2025
1 parent fad9107 commit 22d907f
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
});
Expand Down

0 comments on commit 22d907f

Please sign in to comment.