From: Fredrik Tolf Date: Fri, 16 Oct 2009 03:57:50 +0000 (+0200) Subject: Work around Tomcat/AJP bug. X-Git-Url: http://dolda2000.com/gitweb/?p=jsvc.git;a=commitdiff_plain;h=9f01683a8fd45c753e6aa6580705e0810b701355 Work around Tomcat/AJP bug. --- diff --git a/src/dolda/jsvc/j2ee/J2eeRequest.java b/src/dolda/jsvc/j2ee/J2eeRequest.java index 574355f..6b1ba0b 100644 --- a/src/dolda/jsvc/j2ee/J2eeRequest.java +++ b/src/dolda/jsvc/j2ee/J2eeRequest.java @@ -77,7 +77,11 @@ public class J2eeRequest extends ResponseBuffer { public SocketAddress remoteaddr() { try { - return(new InetSocketAddress(InetAddress.getByName(req.getRemoteAddr()), req.getRemotePort())); + /* Apparently getRemotePort returns -1 when running on Tomcat over AJP. */ + int port = req.getRemotePort(); + if(port < 0) + port = 0; + return(new InetSocketAddress(InetAddress.getByName(req.getRemoteAddr()), port)); } catch(UnknownHostException e) { /* req.getRemoteAddr should always be a valid IP address, * so this should never happen. */