From 9f01683a8fd45c753e6aa6580705e0810b701355 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Fri, 16 Oct 2009 05:57:50 +0200 Subject: [PATCH] Work around Tomcat/AJP bug. --- src/dolda/jsvc/j2ee/J2eeRequest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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. */ -- 2.11.0