On Wed, 2 Aug 2023 22:21:20 GMT, Marius Hanl <mh...@openjdk.org> wrote:

> An IOOBE was thrown when scrolling up via the trough (-> 
> `VirtualScrollBar#adjustValue`).
> This happened only when it has bigger cells than the viewport. 
> If the the uppermost cell with the index 0 is only visible (although not 
> completely scrolled to the top) and then an attempt is made to scroll up 
> again, the `VirtualFlow` will try to scroll to the next cell, subtracting 
> index 0 by 1, resulting in -1 -> IOOBE.
> 
> The code now guards against any under or overflow.
> 
> This is technically a regression from 
> https://bugs.openjdk.org/browse/JDK-8173321
> 
> Note: While testing with very big cells, I found out that scrolling via the 
> trough may not work after the first time. 
> This is because the `VirtualFlow` still creates 2 cells, although only one 
> can be visible at a time (and `VirtualScrollBar` does this check, which will 
> never be true then: `firstVisibleCell == lastVisibleCell`). This is unrelated 
> to this fix. I can create a ticket when I have more information.

I'll let others who are more familiar with VirtualFlow formally review it, but 
I left a comment on the fix and test.

modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/VirtualScrollBar.java
 line 144:

> 142:                     index = Math.max(0, index - 1);
> 143:                 } else {
> 144:                     index = Math.max(flow.getCellCount(), index + 1);

Shouldn't this be Math.min?

modules/javafx.controls/src/test/java/test/javafx/scene/control/skin/VirtualFlowTest.java
 line 37:

> 35: import static org.junit.Assert.assertTrue;
> 36: import static org.junit.Assert.fail;
> 37: import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

We do not want to mix JUnit 4 and JUnit 5 calls in the same test class. Since 
converting this class to use JUnit 5 would be out of scope for a bug fix such 
as this, please rewrite it using JUnit 4 API calls only (which probably means a 
try/catch with a "fail" if you don't get the expected exception.

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

PR Review: https://git.openjdk.org/jfx/pull/1194#pullrequestreview-1560899072
PR Review Comment: https://git.openjdk.org/jfx/pull/1194#discussion_r1283076891
PR Review Comment: https://git.openjdk.org/jfx/pull/1194#discussion_r1283074296

Reply via email to