From 0857c3809f9583005f2ee54c21311cd4836a3bf6 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 19 Apr 2023 23:04:01 +0200 Subject: [PATCH] Use logging instead of backtrace for IPv6-addresses when unsupported Throwing backtraces is needlessly expensive and spams the log with no additional gain. --- src/freenet/io/comm/UdpSocketHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freenet/io/comm/UdpSocketHandler.java b/src/freenet/io/comm/UdpSocketHandler.java index c004613a9d2..d21abc8b415 100644 --- a/src/freenet/io/comm/UdpSocketHandler.java +++ b/src/freenet/io/comm/UdpSocketHandler.java @@ -17,6 +17,7 @@ import java.net.InetAddress; import java.net.SocketException; import java.net.SocketTimeoutException; +import java.nio.channels.UnsupportedAddressTypeException; import java.util.Random; import freenet.io.AddressTracker; @@ -338,7 +339,7 @@ public void sendPacket(byte[] blockToSend, Peer destination, boolean allowLocalA boolean isLocal = (!IPUtil.isValidAddress(address, false)) && (IPUtil.isValidAddress(address, true)); collector.addInfo(address, port, 0, getHeadersLength(address) + blockToSend.length, isLocal); if(logMINOR) Logger.minor(this, "Sent packet length "+blockToSend.length+" to "+address+':'+port); - } catch (IOException e) { + } catch (IOException | UnsupportedAddressTypeException e) { if(packet.getAddress() instanceof Inet6Address) { Logger.normal(this, "Error while sending packet to IPv6 address: "+destination+": "+e); } else {