Skip to content

Commit

Permalink
SQOOP-3435 Avoid NullPointerException due to different JSONObject lib…
Browse files Browse the repository at this point in the history
…rary in classpath

Sqoop is expecting the classpath to have org.json [1] as the dependency
but if one uses HADOOP_CLASSPATH to initialize sqoop executor
with com.tdunning open json [2] as the resolution of org.json.JSONObject.
it failed with NullPointerException

1. https://mvnrepository.com/artifact/org.json/json/20090211
2. https://github.com/tdunning/open-json/blob/rc1.8/src/main/java/org/json/JSONObject.java#L141-L155
  • Loading branch information
TAK LON WU committed Apr 2, 2019
1 parent 0216f7f commit e8971b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/java/org/apache/sqoop/util/SqoopJsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ private SqoopJsonUtil() {
}

public static String getJsonStringforMap(Map<String, String> map) {
JSONObject pathPartMap = new JSONObject(map);
Map<String, String> mapToUse = (map == null) ? Collections.emptyMap() : map;
JSONObject pathPartMap = new JSONObject(mapToUse);
return pathPartMap.toString();
}

Expand Down

0 comments on commit e8971b9

Please sign in to comment.