-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MYFACES-4623 check for duplicate ids #607
Conversation
impl/src/main/java/org/apache/myfaces/view/facelets/PartialStateManagementStrategy.java
Outdated
Show resolved
Hide resolved
Thanks - I'm gonna do some testing with this and if everything looks good, I'll merge next week. I'll also get a draft PR up soon for the other duplicate ID exception. |
I'll do TCK testing before any release, so I'll just merge this now now. Edit: Scratch that. I'll keep this PR open, but merge in 4.0 instead. |
i would like to have some tests before merging such a change |
Tried to create a simple scenario, but so far no luck. This DupId Exception is also difficult to replicate easily. I'm not familiar with p:calendar but my suspicion is that the tree under it is creating elements which aren't marked. Thus during the restore phase, the children are simply added. Specifically, it relates to the component resources created by p:calendar. (target is ComponentResourceContainer and the child is jakarta.faces.component.UIOutput. ) This getChildList.add causes the duplicate id exception since restored child elements match an id of an existing element. I believe the faulty element is See error from the original test app:
I'll take another look later. |
I'm not able to reproduce this outside the app. Perhaps you could take a look? I can't create another custom component like p:calendar to replicate this problem with. @tandraschko However. c:forEach is broken and we've had many issues in the past. I'm not too happy with this fix, but, given the state of things with c:forEach, I think we should merge this it. Leo also mentioned here:
It seems to me that this very rare scenario with Resource Dependencies was overlooked? |
i dont know what should be special on p:calendar? it just has |
impl/src/main/java/org/apache/myfaces/view/facelets/PartialStateManagementStrategy.java
Outdated
Show resolved
Hide resolved
I've managed to reproduce it. I also realized my fix was not enough. I can add a test, but I'm not sure how to do it via unit testing. Can I add it as an integration test? |
Test app: myfaces-4623-test.zip |
f2f7f5c
to
19dcec5
Compare
Another thing -- the dup id exception only occurs if STRICT_JSF_2_FACELETS_COMPATIBILITY is true. In general, I think it's best to stay away from the legacy for each handler, but I think this fix could be useful for those experiencing this exception. One concern I have if how we could know that the same component is replaced. However, my thinking is that if the same id was added then the user have encountered a duplicate id exception anyway and the app wouldn't have worked. In this case, we check for the duplicate ids, replace it if found, and, if not, add it anyway. So I don't think it should break any existing users and only help those affected by this dup id issue. Edit: CHECK_ID_PRODUCTION_MODE is auto for production , so I think think error should have still occurred. Testing shows the exception is thrown in production w/ auto. CHECK_ID_PRODUCTION_MODE options:
Might be useful to check for |
19dcec5
to
7adc5c1
Compare
@tandraschko Please look over and provide feedback. Also, let me know where I should add the test. |
@tandraschko Just following up -- let me know your thoughts and the new code & where to place the test. Thanks. |
a integrationtests is ok for me, we just need some auto-testing to avoid breaking again in future |
eb0bf6f
to
ddf32a3
Compare
ddf32a3
to
d1b3851
Compare
* myfaces-4623 check for dup ids to avoid DuplicateIdException * Loop through children to check all ids before adding * Create integration test for myfaces-4623
Draft test fix for https://issues.apache.org/jira/browse/MYFACES-4623
Feel like a band-aid solution on top of another band-aid :/
This could use some refactoring to avoid code duplication?