Closed jcgueriaud1 closed 6 months ago
It's probably related to this changes: https://github.com/vaadin/flow/pull/18535
Looking at the stack trace, it seems a duplicate of (or related to) #18702
The issue is caused by this code in validate()
method
BindingValidationStatus<?> status = bindingValidationStatuses.stream()
.filter(s -> targetBinding.equals(s.getBinding())).findFirst()
.orElse(null);
getValidationStatusHandler().statusChange(new BinderValidationStatus<>(
this, Collections.singletonList(status),
Collections.emptyList()));
Basically, in the reproducer, status
is null, so the BinderValidationStatus
objects gets a collection with a null
element.
To be investigated the reason for the null
status.
It might be because the code is binding the same field twice; probably some cleanup is missing on the second binding.
When the field is bound for the second time, the previous binding is removed from Binder
, but unbind
is not called, so some listeners are still attached to the field.
In BindingBuilderImpl.bind()
we have to change the following part to also unbind the field
getBinder().bindings.removeIf(registeredBinding -> registeredBinding.getField() == field);
Fixes in the latest 24.4 SNAPSHOT seems to prevent the error in the example project. However, I think the replaced binding should be unbound anyway.
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
When I'm calling binder.readBean() I have a BindingException
Expected behavior
No exception
Minimal reproducible example
It happens when I'm using
binder.bindInstanceFields(this);
then bind a field. It doesn't happen if I'm binding the field thenbinder.bindInstanceFields(this);
In 24.3.3, both code were working.
There is a repository to reproduce it: (click on a row to get the exception) https://github.com/jcgueriaud1/binder-test
Versions