commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Bishop (JIRA)" <>
Subject [jira] Created: (COLLECTIONS-217) Flat3Map.Entry.setValue() overwrites other Entry values
Date Tue, 18 Jul 2006 17:43:14 GMT
Flat3Map.Entry.setValue() overwrites other Entry values

                 Key: COLLECTIONS-217
             Project: Commons Collections
          Issue Type: Bug
          Components: Bag
    Affects Versions: 3.2
         Environment: JDK 1.4, WinXP
            Reporter: Matt Bishop
            Priority: Critical

Flat3Map's Entry objects will overwrite other Entry's values if Entry.setValue() is called
on one.  It should only overwrite the Entry at hand.

I've looked at the source, and the case statement incorrectly falls through, rather than returning
like it should:, lines 646-660:

        public Object setValue(Object value) {
            if (canRemove == false) {
                throw new IllegalStateException(AbstractHashedMap.SETVALUE_INVALID);
            Object old = getValue();
            switch (nextIndex) {
                case 3: 
                    parent.value3 = value;
                case 2:
                    parent.value2 = value;
                case 1:
                    parent.value1 = value;
            return old;

With this code, if I set the value of the third item in the EntrySet, then all three values
are set to the new value.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message