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

SQOOP-3435 Avoid NullPointerException due to different JSONObject library in classpath #77

Merged
merged 1 commit into from Apr 3, 2019

Conversation

taklwu
Copy link
Contributor

@taklwu taklwu commented Apr 1, 2019

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

Copy link
Contributor

@szvasas szvasas left a comment

Choose a reason for hiding this comment

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

Hi @taklwu,

Nice catch, thank you for submitting this improvement. I have left a minor comment only.

@@ -40,6 +40,9 @@ private SqoopJsonUtil() {
}

public static String getJsonStringforMap(Map<String, String> map) {
if (map == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: it is a good practice not to reassign the input parameters so I would change this to something like the following:
Map<String, String> mapToUse = (map == null) ? emptyMap() : map; JSONObject pathPartMap = new JSONObject(mapToUse);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review and suggestion, I have updated the commit and SQOOP-3435

…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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants