[weld-issues] [JBoss JIRA] (WELD-2628) AfterTypeDiscovery added alternative gets ineffective priority
Title: Message Title Karl von Randow created an issue Weld / WELD-2628 AfterTypeDiscovery added alternative gets ineffective priority Issue Type: Bug Affects Versions: 3.1.4.Final Assignee: Unassigned Components: Extensions Created: 29/May/20 3:04 PM Priority: Minor Reporter: Karl von Randow When an Extension adds an alternative in AfterTypeDiscovery, the alternative gets assigned a priority by org.jboss.weld.bootstrap.enablement.EnablementListView#getPriority based upon the previous item in the alternatives list (it adds 10). Note that it uses the previous one item only, so it assigns a priority greater than the currently last item, not greater than the priority of any other alternatives. If prior to AfterTypeDiscovery the alternatives list already contains an alternative implementation of FooService with a priority (say 100), but it's not the last item in the alternatives list, then an Extension adds another alternative of FooService, that new alternative will get a priority 10 greater than the priority of the last alternative in the list, but not necessarily greater than 100, and therefore will not be chosen. I believe the order of items in the list of alternatives should be used to choose the alternative implementation. Perhaps the EnablementListView should consider the maximum priority of all entries in the alternatives list when added a new alternative. Perhaps that means a renumbering of priorities on all alternatives is necessary (for when someone goes Integer.MAX_VALUE). I am happy to contribute a patch if I'm on the right track. This may be related to CDI-437.
[weld-issues] [JBoss JIRA] (WELD-2628) AfterTypeDiscovery added alternative gets ineffective priority
Title: Message Title Karl von Randow commented on WELD-2628 Re: AfterTypeDiscovery added alternative gets ineffective priority Matěj Novotný thank you very much for your quick and thorough replies. The list of alternatives accessed is not sorted by priority in Weld 3.1.4 in the case I have observed. Therefore I think Weld has a bug and does not sort by priority in ascending order. I will look at what's involved to create a test case demonstrating this... Add Comment This message was sent by Atlassian Jira (v7.13.8#713008-sha1:1606a5c) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (WELD-2628) AfterTypeDiscovery added alternative gets ineffective priority
Title: Message Title Karl von Randow commented on WELD-2628 Re: AfterTypeDiscovery added alternative gets ineffective priority Matěj Novotný thanks again, especially as it seems there might be something odd with my setup. I can confirm that I do see the getAlternatives list containing two classes at the end that have Integer.MIN_VALUE priority, and others earlier in the list with 100 and 200. I believe I've found the issue. It's the Integer.MIN_VALUE priorities on those two classes. Let me try to excuse myself by saying that those priorities are actually for JAX-RS (as the classes are Filters), and I'm using CXF-CDI so my classes are @Dependent but use @Priority for JAX-RS and aren't actually alternatives. The compareTo function in org.jboss.weld.bootstrap.enablement.Item uses return p1 - p2; as the return value, which hits an integer overflow when p2 == Integer.MIN_VALUE. I'm not clear on whether (large) negative priorities are legal in the CDI spec. They're certainly possible! Perhaps it could be considered a fix to change the compareTo method to avoid integer overflow with a few comparisons? Add Comment This message was sent by Atlassian Jira (v7.13.8#713008-sha1:1606a5c) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (WELD-2628) AfterTypeDiscovery added alternative gets ineffective priority
Title: Message Title Karl von Randow edited a comment on WELD-2628 Re: AfterTypeDiscovery added alternative gets ineffective priority [~manovotn] thanks again, especially as it seems there might be is something odd with my setup.I can _confirm_ that I do see the {{getAlternatives}} list containing two classes at the end that have {{Integer.MIN_VALUE}} priority, and others earlier in the list with {{100}} and {{200}}.I believe I've found the issue. It's the {{Integer.MIN_VALUE}} priorities on those two classes. Let me try to excuse myself by saying that those priorities are actually for JAX-RS (as the classes are Filters), and I'm using CXF-CDI so my classes are {{@Dependent}} but use {{@Priority}} for JAX-RS and aren't actually alternatives.The {{compareTo}} function in {{org.jboss.weld.bootstrap.enablement.Item}} uses {{return p1 - p2;}} as the return value, which hits an integer overflow when {{p2 == Integer.MIN_VALUE}}.I'm not clear on whether (large) negative priorities are legal in the CDI spec. They're certainly possible! Perhaps it could be considered a fix to change the {{compareTo}} method to avoid integer overflow with a few comparisons? Add Comment This message was sent by Atlassian Jira (v7.13.8#713008-sha1:1606a5c) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues
[weld-issues] [JBoss JIRA] (WELD-2628) AfterTypeDiscovery added alternative gets ineffective priority
Title: Message Title Karl von Randow commented on WELD-2628 Re: AfterTypeDiscovery added alternative gets ineffective priority Matěj Novotný I'd be happy to; I hope I've succeeded: https://github.com/weld/core/pull/1999 A pretty auspicious PR number to boot. I made the PR against the 3.1 branch. It apparently doesn't immediately merge against master; I'll happily work that out if targeting master is preferred. Thanks for your assistance with this issue. I've since revised those two fanciful priorities in our application without any impact so I'm not dependent on this fix, but live in hope that it saves some other poor sap a few hours on a Friday some time in the future Add Comment This message was sent by Atlassian Jira (v7.13.8#713008-sha1:1606a5c) ___ weld-issues mailing list weld-issues@lists.jboss.org https://lists.jboss.org/mailman/listinfo/weld-issues