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

Elek, Marton commented on HDDS-328:
-----------------------------------

This is a false positive warning and I didn't find any workaround.

Locally I got the following error:

{code}
[INFO] --- findbugs-maven-plugin:3.0.0:check (default-cli) @ 
hadoop-hdds-container-service ---
[INFO] BugInstance size is 1
[INFO] Error size is 0
[INFO] Total bugs: 1
[INFO] Possible null pointer dereference in 
org.apache.hadoop.ozone.container.keyvalue.TarContainerPacker.extractEntry(TarArchiveInputStream,
 long, Path) due to return value of called method 
["org.apache.hadoop.ozone.container.keyvalue.TarContainerPacker"] At 
TarContainerPacker.java:[lines 52-247]
{code}

It's hard to say what's the problem as lines 52-247 is a huge range.

After a while I found that the problem is with the Files.createDirectories.
It's passed with commenting out the Files.createDirectories line. But path and 
path.getParent is checked before with preconditions check.

{code}
  private void extractEntry(TarArchiveInputStream tarInput, long size,
      Path path) throws IOException {
    Preconditions.checkNotNull(path, "Path element should not be null");
    Preconditions.checkNotNull(path.getParent(), "Path element should "
                                                  + "have a parent directory");
//    Files.createDirectories(path.getParent()); // It's ok without this line 
(wat?)
    try (BufferedOutputStream bos = new BufferedOutputStream(
        new FileOutputStream(path.toAbsolutePath().toString()))) {
      int bufferSize = 1024;
      byte[] buffer = new byte[bufferSize + 1];
      long remaining = size;
      while (remaining > 0) {
        int read =
            tarInput.read(buffer, 0, (int) Math.min(remaining, bufferSize));
        if (read >= 0) {
          remaining -= read;
          bos.write(buffer, 0, read);
        } else {
          remaining = 0;
        }
      }
    }

  }
{code}

Finally I added the issue to the findbugsExclude file:

{code}
diff --git a/hadoop-hdds/container-service/dev-support/findbugsExcludeFile.xml 
b/hadoop-hdds/container-service/dev-support/findbugsExcludeFile.xml
index 3571a8929e3..861d28d6dfb 100644
--- a/hadoop-hdds/container-service/dev-support/findbugsExcludeFile.xml
+++ b/hadoop-hdds/container-service/dev-support/findbugsExcludeFile.xml
@@ -18,4 +18,9 @@
   <Match>
     <Package name="org.apache.hadoop.hdds.protocol.proto"/>
   </Match>
+  <Match>
+    <Class 
name="org.apache.hadoop.ozone.container.keyvalue.TarContainerPacker"/>
+    <Method name="extractEntry"/>
+    <Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
+  </Match>
 </FindBugsFilter>
{code}

> Support export and import of the KeyValueContainer
> --------------------------------------------------
>
>                 Key: HDDS-328
>                 URL: https://issues.apache.org/jira/browse/HDDS-328
>             Project: Hadoop Distributed Data Store
>          Issue Type: Improvement
>          Components: Ozone Datanode
>            Reporter: Elek, Marton
>            Assignee: Elek, Marton
>            Priority: Critical
>             Fix For: 0.2.1
>
>         Attachments: HDDS-328-HDFS-10285.006.patch, HDDS-328.002.patch, 
> HDDS-328.003.patch, HDDS-328.004.patch, HDDS-328.005.patch, HDDS-328.007.patch
>
>
> In HDDS-75 we pack the container data to an archive file, copy to other 
> datanodes and create the container from the archive.
> As I wrote in the comment of HDDS-75 I propose to separate the patch to make 
> it easier to review.
> In this patch we need to extend the existing Container interface with adding 
> export/import methods to save the container data to one binary input/output 
> stream. 
>  



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

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

Reply via email to