Change InetAddress
-String
conversion methods to preserve the scope ID.
#7231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
InetAddress
-String
conversion methods to preserve the scope ID.This matches the behavior in https://bugs.openjdk.org/browse/JDK-8272215 (except still not supporting brackets [])
RELNOTES=
net
: ChangedInetAddress
-String
conversion methods to preserve the scope ID. This may lead to two kinds of problems: First, callers of those methods may be relying on the returned values not to include the scope ID. For example, they might compensate for the old behavior of the methods by appending the scope ID to a returned string themselves. (If so, you can update your code to stop doing so at the same time as you upgrade Guava. Of, if your code might run against multiple versions of Guava, you can check whether Guava included a scope ID before adding one yourself.) Or they may pass the returned string to another system that does not understand scope IDs. (If so, you can strip the scope ID off, whether by truncating the string form at a%
character (leaving behind any trailing]
character in the case offorUriString
) or by replacing the returnedInetAddress
with a new instance constructed by callingInetAddress.getByAddress(addr)
. The other possible cause for problems is thatjava.net.InetAddress
validates any provided scope ID against the interfaces available on the machine. As a result, methods inInetAddresses
may now fail if the scope ID fails validation, including if the code runs in an Android app without networking permission. If this is not the behavior that you want, then you can strip off the scope ID from the input string before passing it to Guava, as discussed above.