On Tue, 21 Dec 2021 12:13:55 GMT, Abhinay Agarwal <d...@openjdk.java.net> wrote:

>> modules/javafx.controls/src/main/java/javafx/scene/control/MultipleSelectionModelBase.java
>>  line 877:
>> 
>>> 875:             if (size >= 0) {
>>> 876:                 return size;
>>> 877:             }
>> 
>> Using lazy evaluation means that you need to be extra careful that the size 
>> is invalidated in all the right places. One method that needs to be checked 
>> is the `set(int index, int... indices)` method. How carefully have you 
>> checked to make sure that nothing that could change the size fails to update 
>> the `size` field?
>> 
>> Related to this, are you satisfied that the current set of unit tests are 
>> sufficient to catch any potential problems, and that you don't need to add 
>> more tests?
>
> Good point. All the test cases that I could think of were already present in 
> `MultipleSelectionModelImplTest`. Nevertheless, test cases for different 
> `set()` methods can definitely be added. I will work on it.

What about the first part of my question? Have you looked at the set logic to 
ensure that `size` is being invalidated in all places it should be. The 
`set(int index, int... indices)` method does not directly invalidate `size`. If 
that method unconditionally set `size = -1`, it would be easier to prove that 
there are no missed cases.

-------------

PR: https://git.openjdk.java.net/jfx/pull/673

Reply via email to