You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Raghu Angadi (JIRA)" <ji...@apache.org> on 2007/05/19 02:12:16 UTC

[jira] Updated: (HADOOP-1392) FindBugs : Fix some correctness bugs reported in DFS, FS, etc.

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

Raghu Angadi updated HADOOP-1392:
---------------------------------

    Attachment: HADOOP-1392-01.patch

Attached patch fixes some of the correctness issues reported. FindBugs is pretty good. The following are some of the bugs fixed in this patch (findBugs' explation is after the affected code):

{code:title=NamenodeFsck.java:421}
chosenNode = nodes[Math.abs(r.nextInt())  % nodes.length];
{code} (!) *Bad attempt to compute absolute value of signed 32-bit random integer* :
This code generates a random signed integer and then computes the absolute value of that random integer. If the number returned by the random number generator is Integer.MIN_VALUE, then the result will be negative as well (since Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE).

{code:title=FSImage.java:571}
isUpgradeFinalized &= !sd.getPreviousDir().exists();
{code} (!) *Potentially dangerous use of non-short-circuit logic* :
This code seems to be using non-short-circuit logic (e.g., & or |) rather than short-circuit logic (&& or ||). In addition, it seem possible that, depending on the value of the left hand side, you might not want to evaluate the right hand side (because it would have side effects, could cause an exception or could be expensive.
Non-short-circuit logic causes both sides of the expression to be evaluated even when the result can be inferred from knowing the left-hand side. This can be less efficient and can result in errors if the left-hand side guards cases when evaluating the right-hand side can generate an error.
See the Java Language Specification for details.
{code:title=FileSystem.java:227}
    if (!(this.getUri().getScheme().equals(uri.getScheme()) &&
          (thisAuthority == null && thatAuthority == null)
          || thisAuthority.equals(thatAuthority)))
      throw new IllegalArgumentException("Wrong FS: "+path+
                                         ", expected: "+this.getUri());
{code} (!) *Possible null pointer dereference* :
A reference value dereferenced here might be null at runtime.  This may lead to a NullPointerException when the code is executed.

> FindBugs : Fix some correctness bugs reported in DFS, FS, etc.
> --------------------------------------------------------------
>
>                 Key: HADOOP-1392
>                 URL: https://issues.apache.org/jira/browse/HADOOP-1392
>             Project: Hadoop
>          Issue Type: Bug
>    Affects Versions: 0.12.3
>            Reporter: Raghu Angadi
>         Assigned To: Raghu Angadi
>             Fix For: 0.14.0
>
>         Attachments: HADOOP-1392-01.patch
>
>
> Fix some correctness bugs reported by FindBugs in DFS, FS, IO, NET, etc packages.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.