[ 
https://issues.apache.org/jira/browse/MAPREDUCE-6715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15802717#comment-15802717
 ] 

Yufei Gu commented on MAPREDUCE-6715:
-------------------------------------

Thanks for the review. After deeper looking, I realize this complain about NPE 
is because the code analyzer cannot tell whether two separate code section are 
in the same condition. For example, section1 and section2 in the following code 
are under the same condition, but code analyzer cannot tell.  I adjusted the 
code a little, hopefully it will work for the code analyzer, but it is NOT an 
issue anyway. We may need a smarter code analyzer. 
{code}
    CompressionCodec codec = null;
    String extension = "";
    if (isCompressed) {
      // section1
      Class<? extends CompressionCodec> codecClass = 
        getOutputCompressorClass(job, GzipCodec.class);
      codec = (CompressionCodec) ReflectionUtils.newInstance(codecClass, conf);
      extension = codec.getDefaultExtension();
    }
    Path file = getDefaultWorkFile(job, extension);
    FileSystem fs = file.getFileSystem(conf);
    if (!isCompressed) {
      FSDataOutputStream fileOut = fs.create(file, false);
      return new LineRecordWriter<K, V>(fileOut, keyValueSeparator);
    } else {
     //section2
      FSDataOutputStream fileOut = fs.create(file, false);
      return new LineRecordWriter<K, V>(new DataOutputStream
                                        (codec.createOutputStream(fileOut)),
                                        keyValueSeparator);
    }
{code}

> Fix Bad Practices
> -----------------
>
>                 Key: MAPREDUCE-6715
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-6715
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>    Affects Versions: 2.9.0
>            Reporter: Yufei Gu
>            Assignee: Yufei Gu
>         Attachments: MAPREDUCE-6715.001.patch, MAPREDUCE-6715.002.patch, 
> MAPREDUCE-6715.003.patch, MAPREDUCE-6715.004.patch, MAPREDUCE-6715.005.patch
>
>
> {code}
> Null Dereference        CleanupQueue.java:139
> Weak SecurityManager Check: Overridable Method  
> LocalDistributedCacheManager.java:229
> Null Dereference        TextOutputFormat.java:137
> Null Dereference        ShuffleSchedulerImpl.java:422
> Null Dereference        MapTask.java:415
> Null Dereference        Pentomino.java:160
> Unreleased Resource: Streams    TeraScheduler.java:77
> Unreleased Resource: Streams    CLI.java:570
> Null Dereference        CLI.java:370
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to