Skip to content

Commit

Permalink
pool: http-tpc fix NPE when monitoring network traffic
Browse files Browse the repository at this point in the history
Motivation:

A recently commited patch added support for monitoring over which TCP
connection an HTTP-TPC data transfer is taking place.  Unfortunately,
this patch contained a race condition between the HTTP client
establishing the TCP connection and the monitoring code querying over
which connection the transfer is taking place.

If the monitoring wins the race then a NullPointerException is logged.

Modification

Update code so it understands that a connection might not (yet) be
connected.

Result:

An unreleased regression is fixed.

Target: master
Request: 7.0
Request: 6.2
Patch: https://rb.dcache.org/r/12709/
Acked-by: Lea Morschel
  • Loading branch information
paulmillar committed Sep 24, 2021
1 parent 3d87507 commit e664995
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
import static com.google.common.collect.Maps.uniqueIndex;
import static diskCacheV111.util.ThirdPartyTransferFailedCacheException.checkThirdPartyTransferSuccessful;
import static dmg.util.Exceptions.getMessageWithCauses;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.dcache.namespace.FileAttribute.CHECKSUM;
import static org.dcache.util.ByteUnit.GiB;
Expand Down Expand Up @@ -409,7 +408,12 @@ private Optional<InetSocketAddress> remoteAddress()
}

try {
InetAddress addr = requireNonNull(inetConn.getRemoteAddress());
InetAddress addr = inetConn.getRemoteAddress();
if (addr == null) {
_log.debug("HttpInetConnection is not connected.");
return Optional.empty();
}

int port = inetConn.getRemotePort();
InetSocketAddress sockAddr = new InetSocketAddress(addr, port);
return Optional.of(sockAddr);
Expand Down

0 comments on commit e664995

Please sign in to comment.