-
Notifications
You must be signed in to change notification settings - Fork 463
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
8330462: StringIndexOutOfBoundException when typing anything into TextField #1442
Conversation
👋 Welcome back koppor! A progress list of the required criteria for merging this PR into |
@koppor This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 8 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@andy-goryachev-oracle, @kevinrushforth, @arapte) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
/reviewers 2 |
@andy-goryachev-oracle |
would this fix need to be backported? how far back? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks right. I can't verify the fix with the deepl app.
modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java
Outdated
Show resolved
Hide resolved
In addition to the comment Andy made about possible other places for the check, I'd like to see a test, if possible. Also, this doesn't follow the usual pattern of checking for integer overflow, so that could be done in the utility method that Andy suggested. /reviewers 2 |
@kevinrushforth |
Where can I find hints on this? I would use TestFX, fire up some minimal app and try to hit the branches of WinTextRangeProvider. However, I did not find TestFX as used. And there is no I assume, I need to create some class in Based on my experience, I would create a test for |
Yes - JavaFX 22 would be helpful for me.
Since EOL of JavaFX in Java 8 is less than 12 months from now, I would not do it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one inline comment.
I'd like @arapte to review this, since he is familiar with this code, having fixed other IOOBE bugs in it.
modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java
Outdated
Show resolved
Hide resolved
Reviewers: @arapte @andy-goryachev-oracle |
Based on what I see from the stacktrace, this sounds good. We now know that the methods in WinTextRangeProvider can be invoked with bogus values. A good test would invoke those methods with bogus values and detect a non-catched Exception before, and no Exception after the patch. This can easily be done with a unit test, no need to fire up a minimal app. |
How to create an instance of |
I am new to testing in the JFX project. It seems that However, now I get the (expected) error that the module
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test gets an error on Mac and Linux. See inline comments.
|
||
@AfterAll | ||
static void shutdown() { | ||
Util.shutdown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails on Mac and Linux because the initialization (and consequently all tests) are skipped, but the call to Util.shutdown
is not skipped. You will either need to also add assumeTrue(PlatformUtil.isWindows());
here or else move the assumeTrue
to the test method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a good way to skip the whole file entirely, e.g. via junit annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still want to use assumeTrue
as the pattern (for flexibility), so the question is whether there is a better place besides a method annotated with @BeforeAll
to put it (which also means duplicating the assumption in the @AfterAll
method). I'm not aware of one, but maybe someone else is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My source: https://stackoverflow.com/q/30112317/873282, but I did totally forget about @AfterAll
. I was assuming that that would also have been skipped if the @BeforeAll
was skipped. 🙈
Think, for users coming from JUnit4, it is better to put the statements in each test method, even though not executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Junit 5 has an EnabledOnOs annotation https://junit.org/junit5/docs/5.2.0/api/org/junit/jupiter/api/condition/EnabledOnOs.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EnabledOnOs
thank you @Siedlerchr for this info.
I wonder what criteria are set for determining the OS value, and do they match jfx ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They just read the os.name
with `System.getProperty("os.name") but that only includes the Standard values.
https://github.com/junit-team/junit5/blob/db47616ab4ccf38ff63e8bff41050d5102c9ff15/junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/OS.java#L110
This only includes the standard OS values. However, an alternative could be to use @EnabledIf("isWindows")
with a method of that name that returns a boolean
boolean isWindows() {
return PlatformUtil.isWindows()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic is different, but both variants should be ok for testing purposes.
for example,
junit: mac = toLowercase(ENGLISH).contains("mac")
jfx: mac = startsWith("Mac")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to stick with assumptions since that's what we use everywhere else. Also, it gives us more control.
So while we could do something else in the future, this PR isn't the place to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes look good to me; don't see any problems testing with Narrator on win11. I do have Deepl installed (though it is not connected due to proxy). See no issues in TextField, PasswordField, TextArea in the test app as well as the Monkey Tester.
(once the tests are fixed, I'll re-approve)
|
please do not integrate before tests are fixed... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I confirm that the test passes on Windows and is skipped on macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@koppor This is now ready for you to |
/integrate |
/sponsor |
Going to push as commit d3da033.
Your commit was automatically rebased without conflicts. |
@kevinrushforth @koppor Pushed as commit d3da033. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
@arapte @andy-goryachev-oracle @kevinrushforth Thank you for your ongoing support, deep analysis (both the issue and the algorithms needed), and code pointers and guidance. Looking forward to the next JavaFX release where this fix is included! |
Thank you @koppor for fixing the issue! |
It should be available in the next EA build of JavaFX 23. @arapte will backport it to jfx22u for JavaFX 22.0.2. |
Fixes https://bugs.openjdk.org/browse/JDK-8330462.
If the parameter
maxLength
is larger thanInteger.MAX_VALUE - start
, then an addition ofstart
to it leads to a negative value. This is "fixed" by usingMath.max
comparing themaxLength
andmaxLength + start
.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1442/head:pull/1442
$ git checkout pull/1442
Update a local copy of the PR:
$ git checkout pull/1442
$ git pull https://git.openjdk.org/jfx.git pull/1442/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1442
View PR using the GUI difftool:
$ git pr show -t 1442
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1442.diff
Webrev
Link to Webrev Comment