You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "jungm (via GitHub)" <gi...@apache.org> on 2026/10/12 11:14:03 UTC
[PR] MYFACES-4770: ViewScopeCDIMap.put() returns the previous value [myfaces]
jungm opened a new pull request, #1112:
URL: https://github.com/apache/myfaces/pull/1112
https://issues.apache.org/jira/browse/MYFACES-4770
## Summary
`ViewScopeCDIMap.put()` returned the previous internal `ContextualInstanceInfo` wrapper instead of the previous value, breaking the `java.util.Map#put` contract that `UIViewRoot#getViewMap()` exposes. It now unwraps the result the same way `get()` and `remove()` already do:
```diff
ContextualInstanceInfo info = new ContextualInstanceInfo();
info.setContextualInstance(value);
-return getCreationalContextInstances().put(beanKey, info);
+ContextualInstanceInfo previous = getCreationalContextInstances().put(beanKey, info);
+return previous == null ? null : previous.getContextualInstance();
```
## Evidence
New `ViewScopeCDIMapTest` (CDI request test case, so the view map is backed by `ViewScopeCDIMap`):
```text
viewMap.put("key", "first") -> null
viewMap.put("key", "second") -> "first"
viewMap.get("key") -> "second"
```
- **Before:** `AssertionFailedError: expected: <first> but was: <or...@42273aa0>`
**After:** passes; `impl` 1710 tests, 0 failures, 0 errors (JDK 17)
## Merge Danger
**Door:** two-way
**Blast Radius:** small
Only callers that use the return value of `getViewMap().put(...)` with CDI enabled see a difference, and they now get the value the `Map` contract promises instead of a MyFaces-internal object. Nothing inside MyFaces reads that return value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@myfaces.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MYFACES-4770: ViewScopeCDIMap.put() returns the previous value [myfaces]
Posted by "tandraschko (via GitHub)" <gi...@apache.org>.
tandraschko merged PR #1112:
URL: https://github.com/apache/myfaces/pull/1112
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@myfaces.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org