directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shawn McKinney (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FC-107) very dubious code in RoleDAO.update(Role)
Date Wed, 20 May 2015 12:28:00 GMT

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

Shawn McKinney commented on FC-107:
-----------------------------------

Good catch!  Role occupants is modified only on assign/deassignUser functions and does not
belong there.

> very dubious code in RoleDAO.update(Role)
> -----------------------------------------
>
>                 Key: FC-107
>                 URL: https://issues.apache.org/jira/browse/FC-107
>             Project: FORTRESS
>          Issue Type: Bug
>    Affects Versions: 1.0.0-RC40
>            Reporter: Emmanuel Lecharny
>
> While cleaning some of the Sonar issue, I found some piece of code that I think is, at
best, dubious, in {{RoleDAO.update(Role) }}, line 204 :
> {code}
>             if ( VUtil.isNotNullOrEmpty( entity.getOccupants() ) )
>             {
>                 for ( String name : entity.getOccupants() )
>                 {
>                     mods.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
>                         SchemaConstants.ROLE_OCCUPANT_AT, entity.getOccupants().toArray(
new String[]
>                             {} ) ) );
>                 }
>             }
> {code}
> The {{name}} variable is never used, and this will create as many modifications as we
have names in the list. It will work, but here, tehre are two options :
> - either it's just an ineffective way of doing that, as the loop is useless
> - or there is something missing, like using the name for some purpose.



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

Mime
View raw message