HADOOP-11589. NetUtils.createSocketAddr should trim the input URI. Contributed by Rakesh R.
This commit is contained in:
parent
6804d68901
commit
965ce9e24e
@ -602,6 +602,9 @@ Release 2.7.0 - UNRELEASED
|
||||
HADOOP-9869. Configuration.getSocketAddr()/getEnum() should use
|
||||
getTrimmed(). (Tsuyoshi Ozawa via aajisaka)
|
||||
|
||||
HADOOP-11589. NetUtils.createSocketAddr should trim the input URI.
|
||||
(Rakesh R via ozawa)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HADOOP-11323. WritableComparator#compare keeps reference to byte array.
|
||||
|
@ -189,6 +189,7 @@ public static InetSocketAddress createSocketAddr(String target,
|
||||
throw new IllegalArgumentException("Target address cannot be null." +
|
||||
helpText);
|
||||
}
|
||||
target = target.trim();
|
||||
boolean hasScheme = target.contains("://");
|
||||
URI uri = null;
|
||||
try {
|
||||
|
@ -1480,6 +1480,16 @@ public void run() {
|
||||
// it's expected behaviour.
|
||||
}
|
||||
|
||||
public void testTrimCreateSocketAddress() {
|
||||
Configuration conf = new Configuration();
|
||||
NetUtils.addStaticResolution("host", "127.0.0.1");
|
||||
final String defaultAddr = "host:1 ";
|
||||
|
||||
InetSocketAddress addr = NetUtils.createSocketAddr(defaultAddr);
|
||||
conf.setSocketAddr("myAddress", addr);
|
||||
assertEquals(defaultAddr.trim(), NetUtils.getHostPortString(addr));
|
||||
}
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
junit.textui.TestRunner.main(new String[]{
|
||||
TestConfiguration.class.getName()
|
||||
|
Loading…
Reference in New Issue
Block a user