Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
SQOOP-3435: Avoid NullPointerException due to different JSONObject li…
Browse files Browse the repository at this point in the history
…brary in classpath
  • Loading branch information
taklwu authored and szvasas committed Apr 3, 2019
1 parent 0216f7f commit e90e244
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/java/org/apache/sqoop/util/SqoopJsonUtil.java
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

1 comment on commit e90e244

@maningbo
Copy link

@maningbo maningbo commented on e90e244 Mar 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

实际编译过程中遇到问题:
错误: 不兼容的类型: Map<? extends Object,? extends Object>无法转换为Map<String,String>
改成下面这样可以编译通过:
private static final Map EMPTY_MAP = new HashMap<String, String>();
public static String getJsonStringforMap(Map<String, String> map) {
Map<String, String> mapToUse = (map == null) ? EMPTY_MAP : map;
JSONObject pathPartMap = new JSONObject(mapToUse);
return pathPartMap.toString();
}

Please sign in to comment.