hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oz...@apache.org
Subject [2/2] hadoop git commit: HADOOP-11589. NetUtils.createSocketAddr should trim the input URI. Contributed by Rakesh R.
Date Sat, 14 Feb 2015 15:34:50 GMT
HADOOP-11589. NetUtils.createSocketAddr should trim the input URI. Contributed by Rakesh R.

(cherry picked from commit ef950ea1c08f5a95137a95df6d4c90241a25b70e)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b7836c18
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b7836c18
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b7836c18

Branch: refs/heads/branch-2
Commit: b7836c18e47a2ea4afe3b674a88b0aa6cf0a8a52
Parents: 481124b
Author: Tsuyoshi Ozawa <ozawa@apache.org>
Authored: Sun Feb 15 00:30:46 2015 +0900
Committer: Tsuyoshi Ozawa <ozawa@apache.org>
Committed: Sun Feb 15 00:31:33 2015 +0900

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt          |  3 +++
 .../src/main/java/org/apache/hadoop/net/NetUtils.java    |  1 +
 .../test/java/org/apache/hadoop/net/TestNetUtils.java    | 11 +++++++++++
 3 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b7836c18/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 e354682..ff71162 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -197,6 +197,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/b7836c18/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/b7836c18/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
index 319e8a9..a12054b 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/TestNetUtils.java
@@ -643,6 +643,17 @@ public class TestNetUtils {
     assertNotNull(NetUtils.getHostNameOfIP("127.0.0.1:1"));
   }
 
+  @Test
+  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));
+  }
+
   private <T> void assertBetterArrayEquals(T[] expect, T[]got) {
     String expectStr = StringUtils.join(expect, ", ");
     String gotStr = StringUtils.join(got, ", ");


Mime
View raw message