This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new 65fb1ee NPE protection primarily for access log 65fb1ee is described below commit 65fb1ee548111021edde247f3b3c409ec95a5183 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu May 30 17:31:47 2019 +0100 NPE protection primarily for access log --- java/org/apache/tomcat/util/net/NioEndpoint.java | 50 ++++++++++++++++-------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index 68f401a..d41898d 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -1314,20 +1314,26 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> @Override protected void populateRemoteAddr() { - InetAddress inetAddr = getSocket().getIOChannel().socket().getInetAddress(); - if (inetAddr != null) { - remoteAddr = inetAddr.getHostAddress(); + SocketChannel sc = getSocket().getIOChannel(); + if (sc != null) { + InetAddress inetAddr = sc.socket().getInetAddress(); + if (inetAddr != null) { + remoteAddr = inetAddr.getHostAddress(); + } } } @Override protected void populateRemoteHost() { - InetAddress inetAddr = getSocket().getIOChannel().socket().getInetAddress(); - if (inetAddr != null) { - remoteHost = inetAddr.getHostName(); - if (remoteAddr == null) { - remoteAddr = inetAddr.getHostAddress(); + SocketChannel sc = getSocket().getIOChannel(); + if (sc != null) { + InetAddress inetAddr = sc.socket().getInetAddress(); + if (inetAddr != null) { + remoteHost = inetAddr.getHostName(); + if (remoteAddr == null) { + remoteAddr = inetAddr.getHostAddress(); + } } } } @@ -1335,31 +1341,43 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel> @Override protected void populateRemotePort() { - remotePort = getSocket().getIOChannel().socket().getPort(); + SocketChannel sc = getSocket().getIOChannel(); + if (sc != null) { + remotePort = sc.socket().getPort(); + } } @Override protected void populateLocalName() { - InetAddress inetAddr = getSocket().getIOChannel().socket().getLocalAddress(); - if (inetAddr != null) { - localName = inetAddr.getHostName(); + SocketChannel sc = getSocket().getIOChannel(); + if (sc != null) { + InetAddress inetAddr = sc.socket().getInetAddress(); + if (inetAddr != null) { + localName = inetAddr.getHostName(); + } } } @Override protected void populateLocalAddr() { - InetAddress inetAddr = getSocket().getIOChannel().socket().getLocalAddress(); - if (inetAddr != null) { - localAddr = inetAddr.getHostAddress(); + SocketChannel sc = getSocket().getIOChannel(); + if (sc != null) { + InetAddress inetAddr = sc.socket().getInetAddress(); + if (inetAddr != null) { + localAddr = inetAddr.getHostAddress(); + } } } @Override protected void populateLocalPort() { - localPort = getSocket().getIOChannel().socket().getLocalPort(); + SocketChannel sc = getSocket().getIOChannel(); + if (sc != null) { + localPort = sc.socket().getLocalPort(); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org