You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Giamma (JIRA)" <ji...@apache.org> on 2006/07/06 02:40:29 UTC

[jira] Created: (DIRSERVER-664) ExceptionService.modify() is not generating the correct exception

ExceptionService.modify() is not generating the correct exception
-----------------------------------------------------------------

         Key: DIRSERVER-664
         URL: http://issues.apache.org/jira/browse/DIRSERVER-664
     Project: Directory ApacheDS
        Type: Bug

    Versions: 1.0-RC4    
    Reporter: Giamma
    Priority: Minor



When trying to modify an attribute with an existing value, the following exception should be generated:
LdapAttributeInUseException( "Trying to add existing value 'XYZ' to attribute ABC");

But instead the code is generating a IndexOutOfBoundsException because there is a bug in the code that is generating the correct exception.

This is the wrong code:

 public void modify( NextInterceptor nextInterceptor, Name name, ModificationItem[] items ) throws NamingException
    {
        // check if entry to modify exists
        String msg = "Attempt to modify non-existant entry: ";
        assertHasEntry( nextInterceptor, msg, name );

        Attributes entry = nexus.lookup( name );
        for ( int ii = 0; ii < items.length; ii++ )
        {
            if ( items[ii].getModificationOp() == DirContext.ADD_ATTRIBUTE )
            {
                Attribute modAttr = items[ii].getAttribute();
                Attribute entryAttr = entry.get( modAttr.getID() );

                if ( entryAttr != null )
                {
                    for ( int jj = 0; jj < modAttr.size(); jj++ )
                    {
                        if ( entryAttr.contains( modAttr.get( jj ) ) )
                        {
                            throw new LdapAttributeInUseException( "Trying to add existing value '"
                                    + modAttr.get( ii ) + "' to attribute " + modAttr.getID() );                                   <----- HERE IS THE PROBLEM, should use modAttr.get( jj ) 
                        }
                    }
                }
            }
        }
        nextInterceptor.modify( name, items );
    }



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (DIRSERVER-664) ExceptionService.modify() is not generating the correct exception

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRSERVER-664?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny closed DIRSERVER-664.
---------------------------------------


closed

> ExceptionService.modify() is not generating the correct exception
> -----------------------------------------------------------------
>
>                 Key: DIRSERVER-664
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-664
>             Project: Directory ApacheDS
>          Issue Type: Bug
>    Affects Versions: 1.0-RC4
>            Reporter: Giamma
>            Assignee: Emmanuel Lecharny
>            Priority: Minor
>
> When trying to modify an attribute with an existing value, the following exception should be generated:
> LdapAttributeInUseException( "Trying to add existing value 'XYZ' to attribute ABC");
> But instead the code is generating a IndexOutOfBoundsException because there is a bug in the code that is generating the correct exception.
> This is the wrong code:
>  public void modify( NextInterceptor nextInterceptor, Name name, ModificationItem[] items ) throws NamingException
>     {
>         // check if entry to modify exists
>         String msg = "Attempt to modify non-existant entry: ";
>         assertHasEntry( nextInterceptor, msg, name );
>         Attributes entry = nexus.lookup( name );
>         for ( int ii = 0; ii < items.length; ii++ )
>         {
>             if ( items[ii].getModificationOp() == DirContext.ADD_ATTRIBUTE )
>             {
>                 Attribute modAttr = items[ii].getAttribute();
>                 Attribute entryAttr = entry.get( modAttr.getID() );
>                 if ( entryAttr != null )
>                 {
>                     for ( int jj = 0; jj < modAttr.size(); jj++ )
>                     {
>                         if ( entryAttr.contains( modAttr.get( jj ) ) )
>                         {
>                             throw new LdapAttributeInUseException( "Trying to add existing value '"
>                                     + modAttr.get( ii ) + "' to attribute " + modAttr.getID() );                                   <----- HERE IS THE PROBLEM, should use modAttr.get( jj ) 
>                         }
>                     }
>                 }
>             }
>         }
>         nextInterceptor.modify( name, items );
>     }

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


[jira] Commented: (DIRSERVER-664) ExceptionService.modify() is not generating the correct exception

Posted by "Gianmaria Clerici (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/DIRSERVER-664?page=comments#action_12447660 ] 
            
Gianmaria Clerici commented on DIRSERVER-664:
---------------------------------------------


   [[ Old comment, sent by email on Thu, 27 Jul 2006 19:43:29 -0700 ]]

You are welcome.

But I can do better then that :-)

CIAO


Gianmaria Clerici aka Giamma
Email <ma...@giamma.com>gianmaria@giamma.com
Mobile +1 415 290-9502 Home +1 415 626-8394
AOL/YAHOO IM giamma13 SMS giamma@tmomail.net
    * <http://dj.giamma.com/>dj.giamma.com
    * www.triplepower.org
    * <http://people.tribe.net/giamma/blog>people.tribe.net/giamma/blog
    * www.flickr.com/photos/giamma
    * www.youtube.com/user/giamma


> ExceptionService.modify() is not generating the correct exception
> -----------------------------------------------------------------
>
>                 Key: DIRSERVER-664
>                 URL: http://issues.apache.org/jira/browse/DIRSERVER-664
>             Project: Directory ApacheDS
>          Issue Type: Bug
>    Affects Versions: 1.0-RC4
>            Reporter: Giamma
>         Assigned To: Emmanuel Lecharny
>            Priority: Minor
>
> When trying to modify an attribute with an existing value, the following exception should be generated:
> LdapAttributeInUseException( "Trying to add existing value 'XYZ' to attribute ABC");
> But instead the code is generating a IndexOutOfBoundsException because there is a bug in the code that is generating the correct exception.
> This is the wrong code:
>  public void modify( NextInterceptor nextInterceptor, Name name, ModificationItem[] items ) throws NamingException
>     {
>         // check if entry to modify exists
>         String msg = "Attempt to modify non-existant entry: ";
>         assertHasEntry( nextInterceptor, msg, name );
>         Attributes entry = nexus.lookup( name );
>         for ( int ii = 0; ii < items.length; ii++ )
>         {
>             if ( items[ii].getModificationOp() == DirContext.ADD_ATTRIBUTE )
>             {
>                 Attribute modAttr = items[ii].getAttribute();
>                 Attribute entryAttr = entry.get( modAttr.getID() );
>                 if ( entryAttr != null )
>                 {
>                     for ( int jj = 0; jj < modAttr.size(); jj++ )
>                     {
>                         if ( entryAttr.contains( modAttr.get( jj ) ) )
>                         {
>                             throw new LdapAttributeInUseException( "Trying to add existing value '"
>                                     + modAttr.get( ii ) + "' to attribute " + modAttr.getID() );                                   <----- HERE IS THE PROBLEM, should use modAttr.get( jj ) 
>                         }
>                     }
>                 }
>             }
>         }
>         nextInterceptor.modify( name, items );
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (DIRSERVER-664) ExceptionService.modify() is not generating the correct exception

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/DIRSERVER-664?page=all ]

Emmanuel Lecharny resolved DIRSERVER-664.
-----------------------------------------

    Resolution: Fixed
      Assignee: Emmanuel Lecharny

Thanks a lot Giamma !

The fix was perfect ! 

I added a junit test case just in case, and fixed the code the way you proposed to do.

> ExceptionService.modify() is not generating the correct exception
> -----------------------------------------------------------------
>
>                 Key: DIRSERVER-664
>                 URL: http://issues.apache.org/jira/browse/DIRSERVER-664
>             Project: Directory ApacheDS
>          Issue Type: Bug
>    Affects Versions: 1.0-RC4
>            Reporter: Giamma
>         Assigned To: Emmanuel Lecharny
>            Priority: Minor
>
> When trying to modify an attribute with an existing value, the following exception should be generated:
> LdapAttributeInUseException( "Trying to add existing value 'XYZ' to attribute ABC");
> But instead the code is generating a IndexOutOfBoundsException because there is a bug in the code that is generating the correct exception.
> This is the wrong code:
>  public void modify( NextInterceptor nextInterceptor, Name name, ModificationItem[] items ) throws NamingException
>     {
>         // check if entry to modify exists
>         String msg = "Attempt to modify non-existant entry: ";
>         assertHasEntry( nextInterceptor, msg, name );
>         Attributes entry = nexus.lookup( name );
>         for ( int ii = 0; ii < items.length; ii++ )
>         {
>             if ( items[ii].getModificationOp() == DirContext.ADD_ATTRIBUTE )
>             {
>                 Attribute modAttr = items[ii].getAttribute();
>                 Attribute entryAttr = entry.get( modAttr.getID() );
>                 if ( entryAttr != null )
>                 {
>                     for ( int jj = 0; jj < modAttr.size(); jj++ )
>                     {
>                         if ( entryAttr.contains( modAttr.get( jj ) ) )
>                         {
>                             throw new LdapAttributeInUseException( "Trying to add existing value '"
>                                     + modAttr.get( ii ) + "' to attribute " + modAttr.getID() );                                   <----- HERE IS THE PROBLEM, should use modAttr.get( jj ) 
>                         }
>                     }
>                 }
>             }
>         }
>         nextInterceptor.modify( name, items );
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira