You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sqoop.apache.org by "Szabolcs Vasas (JIRA)" <ji...@apache.org> on 2019/04/03 08:41:00 UTC

[jira] [Updated] (SQOOP-3435) Avoid NullPointerException due to different JSONObject library in classpath

     [ https://issues.apache.org/jira/browse/SQOOP-3435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Szabolcs Vasas updated SQOOP-3435:
----------------------------------
    Summary: Avoid NullPointerException due to different JSONObject library in classpath  (was: SqoopOptions missed a null check)

> Avoid NullPointerException due to different JSONObject library in classpath
> ---------------------------------------------------------------------------
>
>                 Key: SQOOP-3435
>                 URL: https://issues.apache.org/jira/browse/SQOOP-3435
>             Project: Sqoop
>          Issue Type: Bug
>    Affects Versions: 1.4.7, 1.5.0
>            Reporter: Tak Lon (Stephen) Wu
>            Priority: Major
>         Attachments: SQOOP-3435.trunk.001.patch, SQOOP-3435.trunk.002.patch
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> In line of [SqoopOptions.java#L785|https://github.com/apache/sqoop/blob/branch-1.4.7/src/java/org/apache/sqoop/SqoopOptions.java#L785] with
> {\{SqoopJsonUtil.getJsonStringforMap((Map) f.get(this))); }}
> Above line should check NULL pointer like in line of [SqoopOptions.java#L778|https://github.com/apache/sqoop/blob/branch-1.4.7/src/java/org/apache/sqoop/SqoopOptions.java#L778] which has
> {{f.get(this) == null ? "null" : f.get(this).toString()}}
> Please see the stacktrace below when running command:
> {{sqoop job --create myjob -- import --connect jdbc:mysql://localhost/db --username root --table employee --m 1}}
> {code:java}
> 19/02/02 01:09:21 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.NullPointerException
> java.lang.NullPointerException
> at org.json.JSONObject.<init>(JSONObject.java:144)
> at org.apache.sqoop.util.SqoopJsonUtil.getJsonStringforMap(SqoopJsonUtil.java:43)
> at org.apache.sqoop.SqoopOptions.writeProperties(SqoopOptions.java:785)
> at org.apache.sqoop.metastore.hsqldb.HsqldbJobStorage.createInternal(HsqldbJobStorage.java:399)
> at org.apache.sqoop.metastore.hsqldb.HsqldbJobStorage.create(HsqldbJobStorage.java:379)
> at org.apache.sqoop.tool.JobTool.createJob(JobTool.java:181)
> at org.apache.sqoop.tool.JobTool.run(JobTool.java:294)
> at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
> at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
> at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
> at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
> at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
> at org.apache.sqoop.Sqoop.main(Sqoop.java:252)
> {code}
> The above {{NullPointerException}} is due to use the of [{{com.tdunning}}|https://github.com/tdunning/open-json/blob/rc1.8/src/main/java/org/json/JSONObject.java#L141-L155] as part of the HIVE libs (if one is reusing the {{HADOOP_CLASSPATH}}) in the classpath. but I think we can better have a checker of {{null}} in {{SqoopJsonUtil.getJsonStringforMap(Map<String, String> map)}} before calling {{JSONObject pathPartMap = new JSONObject(map);}}
> Reporting this bug and the right behavior need to be decided by the assignee. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)