Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix URI construction. #1896

Merged
merged 1 commit into from Jun 3, 2016
Merged

Conversation

zhangkun83
Copy link
Contributor

This fixes two issues.

  1. Use the URI constructor with multiple arguments to construct the placeholder URI for direct address, so that special characters can be correctly escaped. This resolves java.lang.IllegalArgumentException when try to use ipv6 #1883.

It requires the second fix.

  1. Stop URI from mistreating paths as authorities.

There is a bug in URI constructors that take multiple arguments. They simply concatenate escaped components and try to parse the resulting string.

For example, URI("dns", null, "//127.0.0.1", null), which is what we do internally when the application passes "/127.0.0.1" as the target, is supposed to create a [scheme="dns", path="//127.0.0.1"]. Instead, it internally composes "dns://127.0.0.1", which is parsed into [scheme="dns", authority="127.0.0.1"].

To avoid this issue, we pass empty string instead of null as the authority to the URI constructor. The constructor would make "dns:////127.0.0.1" internally which can be parsed correctly.

This fixes two issues.

1) Use the URI constructor with multiple arguments to construct the placeholder
URI for direct address, so that special characters can be correctly
escaped. This resolves grpc#1883.

It requires the second fix.

2) Stop URI from mistreating paths as authorities.

There is a bug in URI constructors that take multiple arguments.  They simply
concatenate escaped components and try to parse the resulting string.

For example, URI("dns", null, "//127.0.0.1", null), which is what we do
internally when the application passes "/127.0.0.1" as the target, is supposed
to create a [scheme="dns", path="//127.0.0.1"].  Instead, it internally composes
"dns://127.0.0.1", which is parsed into [scheme="dns", authority="127.0.0.1"].

To avoid this issue, we pass empty string instead of null as the authority to
the URI constructor. The constructor would make "dns:////127.0.0.1" internally
which can be parsed correctly.
@ejona86
Copy link
Member

ejona86 commented Jun 3, 2016

@zhangkun83 LGTM

@zhangkun83 zhangkun83 merged commit 631a9d5 into grpc:master Jun 3, 2016
@zhangkun83 zhangkun83 deleted the directaddress_ipv6 branch June 3, 2016 00:22
zhangkun83 added a commit to zhangkun83/grpc-java that referenced this pull request Jun 7, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java.lang.IllegalArgumentException when try to use ipv6
2 participants