Skip to content
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

Allow covariant return types during properties collection #20730

Open
s4nf4n opened this issue Dec 16, 2024 · 1 comment
Open

Allow covariant return types during properties collection #20730

s4nf4n opened this issue Dec 16, 2024 · 1 comment

Comments

@s4nf4n
Copy link

s4nf4n commented Dec 16, 2024

Description of the bug

Using Binder with types, that use covariant return types for overridden methods, results in IllegalStateException.

I extended com.vaadin.flow.data.binder.BeanPropertySetTest to reflect this bug. I uploaded a patch under example.

Test result:

java.lang.IllegalStateException: Two property definition for property number are discovered with different types: class java.lang.Number and class java.lang.Integer
	at com.vaadin.flow.data.binder.BeanPropertySet.mergePropertyDefinitions(BeanPropertySet.java:348)
	at java.base/java.util.HashMap.merge(HashMap.java:1383)
	at java.base/java.util.stream.Collectors.lambda$toMap$68(Collectors.java:1673)
	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at com.vaadin.flow.data.binder.BeanPropertySet.<init>(BeanPropertySet.java:333)
	at com.vaadin.flow.data.binder.BeanPropertySet.<init>(BeanPropertySet.java:371)
	at com.vaadin.flow.data.binder.BeanPropertySet.lambda$get$3(BeanPropertySet.java:477)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
	at com.vaadin.flow.data.binder.BeanPropertySet.get(BeanPropertySet.java:477)
	at com.vaadin.flow.data.binder.BeanPropertySetTest.get_beanImplementsSeveralInterfacesWithCovariantReturnTypes_noIllegalState(BeanPropertySetTest.java:389)

Expected behavior

This is valid Java Code. It should be possible to use this with Binder.

Minimal reproducible example

Test_fails_for_covariant_return_types_.patch

Versions

  • Vaadin / Flow version: 24.7-SNAPSHOT
  • Java version: 17
  • OS version: -
  • Browser version (if applicable): -
  • Application Server (if applicable): -
  • IDE (if applicable): -
@s4nf4n
Copy link
Author

s4nf4n commented Dec 16, 2024

See #11410.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Normal Priority (P2)
Development

No branches or pull requests

2 participants