Uploaded image for project: 'Sqoop (Retired)'
  1. Sqoop (Retired)
  2. SQOOP-3435

Avoid NullPointerException due to different JSONObject library in classpath

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.7, 1.5.0
    • 1.4.7, 1.5.0
    • None
    • None

    Description

      In line of SqoopOptions.java#L785 with

      {{SqoopJsonUtil.getJsonStringforMap((Map) f.get(this))); }}

      Above line should check NULL pointer like in line of 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

      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)
      
      

      The above NullPointerException is due to use the of com.tdunning 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.

      Attachments

        1. SQOOP-3435.trunk.002.patch
          1 kB
          Tak-Lon (Stephen) Wu
        2. SQOOP-3435.trunk.001.patch
          1 kB
          Tak-Lon (Stephen) Wu

        Issue Links

          Activity

            People

              taklwu Tak-Lon (Stephen) Wu
              taklwu Tak-Lon (Stephen) Wu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m