Don't NPE when the remote peer address isn't yet known
This appears to be a race condition between the IO processor thread
and the application thread reading the connection table. Apparently
the IO processors can register a session before they have finished
initializing it.
Bug: GERRIT-182
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gerrit/server/ssh/AdminShowConnections.java b/src/main/java/com/google/gerrit/server/ssh/AdminShowConnections.java
index aab8e73..6eb39a5 100644
--- a/src/main/java/com/google/gerrit/server/ssh/AdminShowConnections.java
+++ b/src/main/java/com/google/gerrit/server/ssh/AdminShowConnections.java
@@ -130,6 +130,9 @@
}
private String hostname(final SocketAddress remoteAddress) {
+ if (remoteAddress == null) {
+ return "?";
+ }
String host = null;
if (remoteAddress instanceof InetSocketAddress) {
final InetSocketAddress sa = (InetSocketAddress) remoteAddress;