Repository: hadoop Updated Branches: refs/heads/YARN-2928 e2786151d -> 5a3d0af56
HADOOP-11589. NetUtils.createSocketAddr should trim the input URI. Contributed by Rakesh R. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/965ce9e2 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/965ce9e2 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/965ce9e2 Branch: refs/heads/YARN-2928 Commit: 965ce9e24ed051c6705defc0f85dcfaa4fc9a3ef Parents: 6804d68 Author: Tsuyoshi Ozawa <[email protected]> Authored: Sun Feb 15 00:13:10 2015 +0900 Committer: Tsuyoshi Ozawa <[email protected]> Committed: Sun Feb 15 00:13:10 2015 +0900 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/net/NetUtils.java | 1 + .../java/org/apache/hadoop/conf/TestConfiguration.java | 10 ++++++++++ 3 files changed, 14 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/965ce9e2/hadoop-common-project/hadoop-common/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 99320cb..522ec47 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -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. http://git-wip-us.apache.org/repos/asf/hadoop/blob/965ce9e2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java index ef1092b..e475149 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java @@ -189,6 +189,7 @@ public class NetUtils { throw new IllegalArgumentException("Target address cannot be null." + helpText); } + target = target.trim(); boolean hasScheme = target.contains("://"); URI uri = null; try { http://git-wip-us.apache.org/repos/asf/hadoop/blob/965ce9e2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java index a367553..b7c76eb 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java @@ -1480,6 +1480,16 @@ public class TestConfiguration extends TestCase { // 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()
