Skip to content

[UNDERTOW-1569] HttpServletRequest getLocalName() returns IP instead …#787

Merged
fl4via merged 1 commit intoundertow-io:masterfrom
tmiyargi:UNDERTOW-1569
Jul 29, 2019
Merged

[UNDERTOW-1569] HttpServletRequest getLocalName() returns IP instead …#787
fl4via merged 1 commit intoundertow-io:masterfrom
tmiyargi:UNDERTOW-1569

Conversation

@tmiyargi
Copy link
Copy Markdown
Contributor

public String getLocalName() {
return exchange.getDestinationAddress().getHostString();
String hostName = exchange.getDestinationAddress().getHostName();
if (hostName == null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tmiyargi,

Looking at the javadoc of ServletRequest#getLocalName(), this method should never return a IP address and instead should be a host name. So I don't think we should return an IP address if we can't resolve the host name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaikiran you are correct, but what about backward compatibility? It has been working like this for a long time

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tmiyargi
@fl4via and/or @stuartwdouglas will have a final say on this one. I'm just a lurker in this project.
Having said that, I think the backward compatiblity of this shouldn't play a role here, because this bug fix is about fixing a wrong value that was being retuned, before this change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaikiran I've found in java doc of inetAddr the following:
/** * Gets the host name for this IP address. * * <p>If this InetAddress was created with a host name, * this host name will be remembered and returned; * otherwise, a reverse name lookup will be performed * and the result will be returned based on the system * configured name lookup service. If a lookup of the name service * is required, call * {@link #getCanonicalHostName() getCanonicalHostName}. * * <p>If there is a security manager, its * {@code checkConnect} method is first called * with the hostname and {@code -1} * as its arguments to see if the operation is allowed. * If the operation is not allowed, it will return * the textual representation of the IP address. * * @return the host name for this IP address, or if the operation * is not allowed by the security check, the textual * representation of the IP address. * * @see InetAddress#getCanonicalHostName * @see SecurityManager#checkConnect */

That means an ip could be returned, I don't think there is another way @fl4via, what do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmiyargi I agree, I'm approving this

@tmiyargi tmiyargi force-pushed the UNDERTOW-1569 branch 3 times, most recently from 32f2f8a to 01a2c26 Compare July 19, 2019 12:35
@xstefank
Copy link
Copy Markdown

@fl4via review ping. Can you take a look, please?

@fl4via
Copy link
Copy Markdown
Member

fl4via commented Jul 29, 2019

@xstefank yes, this will go in the next tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants