You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kudu.apache.org by "Todd Lipcon (JIRA)" <ji...@apache.org> on 2017/07/24 22:33:00 UTC

[jira] [Assigned] (KUDU-2058) Java LocatedTablet implementation has sketchy string comparison

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

Todd Lipcon reassigned KUDU-2058:
---------------------------------

    Assignee: Sri Sai Kumar Ravipati

> Java LocatedTablet implementation has sketchy string comparison
> ---------------------------------------------------------------
>
>                 Key: KUDU-2058
>                 URL: https://issues.apache.org/jira/browse/KUDU-2058
>             Project: Kudu
>          Issue Type: Bug
>          Components: client, java
>    Affects Versions: 1.4.0
>            Reporter: Todd Lipcon
>            Assignee: Sri Sai Kumar Ravipati
>              Labels: newbie
>
> Findbugs spotted this issue where two strings are compared by identity instead of content:
> {code}
>   /**
>    * Return the first occurrence for the given role, or null if there is none.
>    */
>   private Replica getOneOfRoleOrNull(Role role) {
>     for (Replica r : replicas) {
>       if (r.getRole() == role.toString()) {
>         return r;
>       }
>     }
>     return null;
>   }
> {code}
> it's not clear why strings are being used for comparison at all rather than checking enum value equality, which would be both faster and more likely to be correct. It may be that this code works fine despite the sketchiness, though, because the two string objects are likely to be derived from the same enumValue.toString() which returns a constant string object.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)