sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kathl...@apache.org
Subject sqoop git commit: SQOOP-2995: backward incompatibility introduced by Custom Tool options (Szabolcs Vasas via Kate Ting)
Date Tue, 16 Aug 2016 05:55:33 GMT
Repository: sqoop
Updated Branches:
  refs/heads/trunk c8f9beec1 -> 3bd2952a9


SQOOP-2995: backward incompatibility introduced by Custom Tool options
(Szabolcs Vasas via Kate Ting)


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

Branch: refs/heads/trunk
Commit: 3bd2952a9b70724f2c180a4b7450043c5de24552
Parents: c8f9bee
Author: Kate Ting <kathleen@apache.org>
Authored: Mon Aug 15 22:55:05 2016 -0700
Committer: Kate Ting <kathleen@apache.org>
Committed: Mon Aug 15 22:55:05 2016 -0700

----------------------------------------------------------------------
 src/java/org/apache/sqoop/util/SqoopJsonUtil.java  | 17 +++++++++--------
 .../org/apache/sqoop/util/TestSqoopJsonUtil.java   | 13 +++++++++++--
 2 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bd2952a/src/java/org/apache/sqoop/util/SqoopJsonUtil.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/util/SqoopJsonUtil.java b/src/java/org/apache/sqoop/util/SqoopJsonUtil.java
index 6e9ed00..adf186b 100644
--- a/src/java/org/apache/sqoop/util/SqoopJsonUtil.java
+++ b/src/java/org/apache/sqoop/util/SqoopJsonUtil.java
@@ -19,6 +19,7 @@
 package org.apache.sqoop.util;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -44,18 +45,18 @@ public class SqoopJsonUtil {
   }
 
   public static Map<String, String> getMapforJsonString(String mapJsonStr) {
-    if ("".equals(mapJsonStr) || null == mapJsonStr) {
-      throw new IllegalArgumentException("Passed Null for map " + mapJsonStr);
-    }
-
     LOG.debug("Passed mapJsonStr ::" + mapJsonStr + " to parse");
-    Map<String, String> partPathMap = new HashMap<String, String>();
-    ObjectMapper mapper = new ObjectMapper();
+    final Map<String, String> result;
     try {
-      partPathMap = mapper.readValue(mapJsonStr,
+      if (isEmptyJSON(mapJsonStr)) {
+        result = Collections.emptyMap();
+      } else {
+        ObjectMapper mapper = new ObjectMapper();
+        result = mapper.readValue(mapJsonStr,
         new TypeReference<HashMap<String, String>>() {
         });
-      return partPathMap;
+      }
+      return result;
     } catch (JsonParseException e) {
       LOG.error("JsonParseException:: Illegal json to parse into map :"
         + mapJsonStr + e.getMessage());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/3bd2952a/src/test/org/apache/sqoop/util/TestSqoopJsonUtil.java
----------------------------------------------------------------------
diff --git a/src/test/org/apache/sqoop/util/TestSqoopJsonUtil.java b/src/test/org/apache/sqoop/util/TestSqoopJsonUtil.java
index ce5f4a4..8b516e8 100644
--- a/src/test/org/apache/sqoop/util/TestSqoopJsonUtil.java
+++ b/src/test/org/apache/sqoop/util/TestSqoopJsonUtil.java
@@ -1,6 +1,7 @@
 package org.apache.sqoop.util;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -50,14 +51,22 @@ public class TestSqoopJsonUtil {
     assertEquals(paramMap, resultMap);
   }
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void testGetMapforJsonStringNullString() {
     Map<String, String> resultMap = SqoopJsonUtil.getMapforJsonString(null);
+    assertTrue(resultMap.isEmpty());
   }
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void testGetMapforJsonStringEmptyString() {
     Map<String, String> resultMap = SqoopJsonUtil.getMapforJsonString("");
+    assertTrue(resultMap.isEmpty());
+  }
+
+  @Test
+  public void testGetMapforJsonStringEmptyMapString() {
+    Map<String, String> resultMap = SqoopJsonUtil.getMapforJsonString("{}");
+    assertTrue(resultMap.isEmpty());
   }
 
   @Test


Mime
View raw message