https://glassfish.dev.java.net/issues/show_bug.cgi?id=132 SECTION: Modified Files ---------------------------- M src/com/sun/faces/context/ExternalContextImpl.java - RequestPramterValuesMap: override containsValue and update equals and hashCode implementations to use java.util.Arrays to determine Array hash codes and equality (necessary as test recently began to fail and is now probably a more accurate implementation). Note: this isn't related to issue 132. M src/com/sun/faces/util/Util.java - Fix for issue 132. Remove extra next() call. This resolves the issue I noticed in the carstore demo last week. SECTION: Diffs ---------------------------- Index: src/com/sun/faces/context/ExternalContextImpl.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/context/ExternalContextImpl.java,v retrieving revision 1.39 diff -u -r1.39 ExternalContextImpl.java --- src/com/sun/faces/context/ExternalContextImpl.java 25 Oct 2005 20:39:56 -0000 1.39 +++ src/com/sun/faces/context/ExternalContextImpl.java 9 Jan 2006 18:29:05 -0000 @@ -46,6 +46,8 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; +import java.util.Arrays; +import java.util.Map.Entry; import javax.faces.FacesException; import javax.faces.context.ExternalContext; @@ -194,7 +196,7 @@ public Map getRequestMap() { if (requestMap == null) { - requestMap = new RequestMap(this.request, this); + requestMap = new RequestMap(this.request); } return requestMap; } @@ -475,9 +477,9 @@ abstract class BaseContextMap extends AbstractMap { - private Set entrySet; - private Set keySet; - private Collection values; + private Set entrySet; + private Set keySet; + private Collection values; // Supported by maps if overridden public void clear() { @@ -490,7 +492,7 @@ throw new UnsupportedOperationException(); } - public Set entrySet() { + public Set entrySet() { if (entrySet == null) { entrySet = new EntrySet(); } @@ -498,7 +500,7 @@ return entrySet; } - public Set keySet() { + public Set keySet() { if (keySet == null) { keySet = new KeySet(); } @@ -506,7 +508,7 @@ return keySet; } - public Collection values() { + public Collection values() { if (values == null) { values = new ValueCollection(); } @@ -929,13 +931,11 @@ class RequestMap extends BaseContextMap { - private final ServletRequest request; - private ExternalContext extContext = null; + private final ServletRequest request; - RequestMap(ServletRequest request, ExternalContext extContext) { - this.request = request; - this.extContext = extContext; + RequestMap(ServletRequest request) { + this.request = request; } public void clear() { @@ -1113,19 +1113,57 @@ } public boolean equals(Object obj) { + if (obj == null || !(obj.getClass() == ExternalContextImpl.theUnmodifiableMapClass)) { return false; } - return super.equals(obj); + Map objMap = (Map) obj; + Set thisKeySet = keySet(); + Set objKeySet = keySet(); + + if (!thisKeySet.equals(objKeySet)) { + return false; + } else { + for (Object key : thisKeySet) { + Object[] thisVal = (Object[]) this.get(key); + Object[] objVal = (Object[]) objMap.get(key); + if (!(Arrays.equals(thisVal, objVal))) { + return false; + } + } + } + + return true; + } - public int hashCode() { + public int hashCode() { int hashCode = 7 * request.hashCode(); - for (Iterator i = entrySet().iterator(); i.hasNext(); ) { - hashCode += i.next().hashCode(); - } + for (Object o : entrySet()) { + Map.Entry entry = (Map.Entry) o; + hashCode += entry.getKey().hashCode(); + hashCode += + (Arrays.hashCode((Object[]) entry.getValue())); + } return hashCode; + } + + public boolean containsValue(Object value) { + + if (value == null || !value.getClass().isArray()) { + return false; + } + + Set entrySet = entrySet(); + for (Object anEntrySet : entrySet) { + Map.Entry entry = (Map.Entry) anEntrySet; + // values will be arrays + if (Arrays.equals((Object[]) value, (Object[]) entry.getValue())) { + return true; + } + } + return false; } // --------------------------------------------- Methods from BaseContextMap Index: src/com/sun/faces/util/Util.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/util/Util.java,v retrieving revision 1.180 diff -u -r1.180 Util.java --- src/com/sun/faces/util/Util.java 2 Dec 2005 17:45:37 -0000 1.180 +++ src/com/sun/faces/util/Util.java 9 Jan 2006 18:29:05 -0000 @@ -752,7 +752,7 @@ while (elements.hasNext()) { Object element = elements.next(); if (SelectItem.class.isInstance(element)) { - list.add((SelectItem) elements.next()); + list.add((SelectItem) element); } else { throw new IllegalArgumentException( Util.getExceptionMessageString(