Index: impl/src/main/java/javax/faces/component/ComponentStateHelper.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/impl/src/main/java/javax/faces/component/ComponentStateHelper.java b/impl/src/main/java/javax/faces/component/ComponentStateHelper.java --- a/impl/src/main/java/javax/faces/component/ComponentStateHelper.java (revision 5f551dd0fd4da6d073ff3528c8ff71b7fab7f180) +++ b/impl/src/main/java/javax/faces/component/ComponentStateHelper.java (date 1650631125648) @@ -60,7 +60,7 @@ this.defaultMap = new HashMap<>(); this.transientState = null; } - + // ------------------------------------------------ Methods from StateHelper @@ -79,13 +79,13 @@ if (retVal == null) { return defaultMap.put(key, value); - } - + } + defaultMap.put(key, value); return retVal; - - } - + + } + return defaultMap.put(key, value); } @@ -104,11 +104,11 @@ if (retVal == null) { return defaultMap.remove(key); } - + defaultMap.remove(key); return retVal; - } - + } + return defaultMap.remove(key); } @@ -119,29 +119,30 @@ public Object put(Serializable key, String mapKey, Object value) { initMap(key); - if (MARK_CREATED.equals(mapKey)) { - if (PropertyKeys.attributes.equals(key)) { - UIComponent parent = component.getParent(); - if (parent != null) { - // remember this component by its mark id - addToDescendantMarkIdCache(parent, component); - } - } - } - Object ret = null; if (component.initialStateMarked()) { Map dMap = (Map) deltaMap.get(key); ret = dMap.put(mapKey, value); } - + Map map = (Map) get(key); if (ret == null) { - return map.put(mapKey, value); - } - - map.put(mapKey, value); + ret = map.put(mapKey, value); + } else { + map.put(mapKey, value); + } + + if (MARK_CREATED.equals(mapKey)) { + if (PropertyKeys.attributes.equals(key)) { + UIComponent parent = component.getParent(); + if (parent != null) { + // remember this component by its mark id + addToDescendantMarkIdCache(parent, component); + } + } + } + return ret; } @@ -187,7 +188,7 @@ @Override public Object eval(Serializable key, Object defaultValue) { Object retVal = get(key); - + if (retVal == null) { ValueExpression valueExpression = component.getValueExpression(key.toString()); if (valueExpression != null) { @@ -210,7 +211,7 @@ if (component.initialStateMarked()) { ((List) deltaMap.get(key)).add(value); } - + List items = (List) get(key); items.add(value); } @@ -232,18 +233,18 @@ @Override public Object remove(Serializable key, Object valueOrKey) { Object source = get(key); - + if (source instanceof Collection) { return removeFromList(key, valueOrKey); } - + if (source instanceof Map) { return removeFromMap(key, valueOrKey.toString()); } - + return null; } - + // ------------------------------------------------ Methods from StateHolder @@ -258,11 +259,11 @@ if (context == null) { throw new NullPointerException(); } - + if (component.initialStateMarked()) { return saveMap(context, deltaMap); - } - + } + return saveMap(context, defaultMap); } @@ -278,7 +279,7 @@ if (context == null) { throw new NullPointerException(); } - + if (state == null) { return; } @@ -294,7 +295,7 @@ if (savedState[savedState.length - 1] != null) { component.initialState = (Boolean) savedState[savedState.length - 1]; } - + int length = (savedState.length - 1) / 2; for (int i = 0; i < length; i++) { Object value = savedState[i * 2 + 1]; @@ -308,7 +309,7 @@ value = value instanceof Serializable ? value : restoreAttachedState(context, value); } } - + if (value instanceof Map) { Map values = (Map)value; @@ -361,7 +362,7 @@ component.getAttributes().put("javax.faces.component.UIComponentBase.attributesThatAreSet", setAttributes); } } - + if (setAttributes != null) { if (value == null) { ValueExpression valueExpression = component.getValueExpression(name); @@ -402,7 +403,7 @@ // so no need to save the state if the saved state is the default. return new Object[] { component.initialStateMarked() }; } - + return null; } @@ -419,11 +420,11 @@ savedState[i * 2 + 1] = value; i++; } - + if (!component.initialStateMarked()) { savedState[savedState.length - 1] = component.initialStateMarked(); } - + return savedState; } @@ -439,7 +440,7 @@ } } } - + Collection list = (Collection) get(key); if (list != null) { if (ret == null) { @@ -447,12 +448,12 @@ } else { list.remove(value); } - + if (list.isEmpty()) { defaultMap.remove(key); } } - + return ret; } @@ -479,11 +480,11 @@ defaultMap.remove(key); } } - + if (ret != null && !component.initialStateMarked()) { deltaMap.remove(key); } - + return ret; } @@ -498,7 +499,7 @@ if (returnValue != null) { return returnValue; } - + return defaultValue; } @@ -507,7 +508,7 @@ if (transientState == null) { transientState = new HashMap<>(); } - + return transientState.put(key, value); }