Bug 48925 - ((ServletRequest) request).getLocalAddr() returns "null"
Summary: ((ServletRequest) request).getLocalAddr() returns "null"
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 6
Classification: Unclassified
Component: Connectors (show other bugs)
Version: 6.0.29
Hardware: All All
: P2 major (vote)
Target Milestone: default
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-16 23:13 UTC by Paul Alesius
Modified: 2010-11-10 14:05 UTC (History)
2 users (show)



Attachments
simple servlet to test getLocalAddr() (1022 bytes, text/plain)
2010-11-05 16:24 UTC, andrea dal farra
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Alesius 2010-03-16 23:13:01 UTC
The getLocalAddr() method returns null when using mod_jk.


I've tried with both mod_jk version 1.2.28 and 1.2.30.
Comment 1 Steven Yates 2010-05-21 02:13:27 UTC
Paul, can you reproduce this with a test case? If so please attach and I will be happy to take a look at it for you.

RGS SY
Comment 2 andrea dal farra 2010-11-05 16:24:07 UTC
Created attachment 26262 [details]
simple servlet to test getLocalAddr()
Comment 3 andrea dal farra 2010-11-05 16:27:43 UTC
Hi Steven,

I've encountered the same problem on iis 7.0 with isapi_Redirect 1.2.31 and i was able to reproduce the issue with mod_jk 1.2.30 with apache 2.2 both in tomcata 5.5 and 6.0.
I'm not familiar with the test case used with mod_jk so i write a simple servlet that echoes the getLocalAddr value.
Is that enough or you need more?

thanks


andrea
Comment 4 andrea dal farra 2010-11-06 09:57:03 UTC
I've tested mod_jk 1.2.30 with Jetty 7.2 and tomcat 7.0.4 and the problem does not occur anymore.
in tomcat-6.0.29 i still have the issue
Comment 5 Rainer Jung 2010-11-06 11:44:38 UTC
I proposed a fix for Tomcat 6. It is available at

http://people.apache.org/~rjung/patches/bz48925-tc6-ajp-localaddr.patch

It only happens for the default implementation of the AJP connector. If you
switch to protocol="org.apache.coyote.ajp.AjpProtocol" in the connector
configuration, it should be fine. That's the implementation used by Tomcat 7.

Note also, that our implementation of localAddr() will simply return the same
as localName(), so you can also switch to that method.

Regards,

Rainer
Comment 6 Rainer Jung 2010-11-10 14:05:03 UTC
Patch applied in r1033643, will be part of Tomcat 6.0.30.
No fix needed and no workaround available for mod_jk.