Closed davidmllr closed 8 months ago
Sounds to me like binding multiple times is a programming eror and a runtime exception is thus acceptable. The regression is on the other hand potentially problematic.
What use case do you have for binding multiple times? Would it make sense to explicitly require that this kind of situation is "acknowledged" in code by calling removeBinding
before binding again?
Thanks for the quick response.
The NPE popped up while testing the upgrade to 24 and I had to look around a bit to find out where it was coming from. Turns out we accidentally had duplicated code in one of our views (containing the binding) which did not throw an exception before.
I think your suggestion of acknowledging the double binding beforehand is great because as a developer I don't really know upfront that using Binder::bind
multiple times is discouraged.
Second binding should probably override the first one without any empty binding leftovers, or at least throw a runtime exception with meaningful message.
This ticket/PR has been released with Vaadin 24.3.6.
This ticket/PR has been released with Vaadin 24.2.11.
Description of the bug
After upgrading from Vaadin 23 to Vaadin 24 our application suddenly starts to throw an NPE when interacting with a field that was bound twice (meaning
Binder::bind
has been called multiple times).This is the exception
Expected behavior
There is no exception. Instead, the last binding should be applied (I guess?).
Minimal reproducible example
The code below generates a view that contains only one text field. After inputting text in the field and blurring the element (e.g. by pressing TAB), the exception described above comes up.
Versions
Flow: 24.3.5 Vaadin: 24.3.5 Java: Eclipse Adoptium 21.0.2 OS: aarch64 Mac OS X 13.4.1 Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Live reload: Java active (Spring Boot Devtools): Front end active