Skip to content

Conversation

@eduardsdv
Copy link
Contributor

@eduardsdv eduardsdv commented Feb 17, 2022

If the InputMethod's node is not in the scene, the default text location point is returned.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8281953: NullPointer in InputMethod components in JFXPanel

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/735/head:pull/735
$ git checkout pull/735

Update a local copy of the PR:
$ git checkout pull/735
$ git pull https://git.openjdk.java.net/jfx pull/735/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 735

View PR using the GUI difftool:
$ git pr show -t 735

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/735.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 17, 2022

👋 Welcome back eduardsdv! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Feb 17, 2022
@mlbridge
Copy link

mlbridge bot commented Feb 17, 2022

Webrevs

Comment on lines +337 to +340
Window window = scene != null ? scene.getWindow() : null;
if (window == null) {
return new Point2D(0, 0);
}
Copy link

@delvh delvh Feb 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as each scene needs to be located in a window, the following will simplify the code:

Suggested change
Window window = scene != null ? scene.getWindow() : null;
if (window == null) {
return new Point2D(0, 0);
}
if (scene == null) {
return new Point2D(0, 0);
}
Window window = scene.getWindow();

Is it possible to have a scene without an assigned window?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the NullPointer occurs here because the synchronization between JavaFx and AWT threads is not really possible in this case, we cannot ensure that this method is only called when the scene is assigned to a window.
I would check here for null both the scene and the window.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a pity. Then ignore this comment.

Copy link
Collaborator

@aghaisas aghaisas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good.

I thought about returning null if either the scene or the window is null. As we need to fix this corner case, whether returning null or the default point (as proposed in this PR) does not matter. Both approaches will work.

  • Have you verified the sample program attached to the JBS runs successfully with your fix?
  • I have a very minor formatting comment on the test.

// Check that no NullPointerException is thrown if the TextField is not in scene
// and that the default point is returned.
Point2D point = textField.getInputMethodRequests().getTextLocation(0);
assertEquals(new Point2D(0,0), point);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor : Please add a space between 0,0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the space and checked the fix again with the sample program.
The fix works, the NullPointer does not occur anymore.

@openjdk
Copy link

openjdk bot commented Feb 22, 2022

@eduardsdv 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:

8281953: NullPointer in InputMethod components in JFXPanel

Reviewed-by: aghaisas

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 1 new commit pushed to the master branch:

  • 418d343: 8281711: Cherry-pick WebKit 613.1 stabilization fixes

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

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 (@aghaisas) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Ready to be integrated label Feb 22, 2022
@eduardsdv
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Ready to sponsor label Feb 22, 2022
@openjdk
Copy link

openjdk bot commented Feb 22, 2022

@eduardsdv
Your change (at version 755444d) is now ready to be sponsored by a Committer.

@aghaisas
Copy link
Collaborator

/sponsor

@openjdk
Copy link

openjdk bot commented Feb 22, 2022

Going to push as commit a0bb545.
Since your change was applied there have been 2 commits pushed to the master branch:

  • 7396396: 8282134: Certain regex can cause a JS trap in WebView
  • 418d343: 8281711: Cherry-pick WebKit 613.1 stabilization fixes

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 22, 2022
@openjdk openjdk bot closed this Feb 22, 2022
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review sponsor Ready to sponsor labels Feb 22, 2022
@openjdk
Copy link

openjdk bot commented Feb 22, 2022

@aghaisas @eduardsdv Pushed as commit a0bb545.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants