Skip to content
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

8264162: PickResult.toString() is missing the closing square bracket #443

Closed

Conversation

@kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Mar 25, 2021

Simple fix to add a missing closing bracket to PickResult::toString. This includes a unit test that fails without the fix and passes with the fix.


Progress

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

Issue

  • JDK-8264162: PickResult.toString() is missing the closing square bracket

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 443

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 25, 2021

👋 Welcome back kcr! 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 label Mar 25, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 25, 2021

Webrevs

@johanvos johanvos self-requested a review Mar 25, 2021
Copy link
Collaborator

@johanvos johanvos left a comment

Good catch. Test fails before and succeeds after the patch.

@openjdk
Copy link

@openjdk openjdk bot commented Mar 25, 2021

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

8264162: PickResult.toString() is missing the closing square bracket

Reviewed-by: jvos, nlisker

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 2 new commits pushed to the master branch:

  • d80b8ad: 8264501: UIWebView for iOS is deprecated
  • ed5cfe7: 8211362: Restrict export of libjpeg symbols from libjavafx_iio.so

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Mar 25, 2021
@@ -203,6 +203,7 @@ public String toString() {
if (getIntersectedTexCoord() != null) {
sb.append(", texCoord = ").append(getIntersectedTexCoord());
Copy link
Collaborator

@nlisker nlisker Mar 25, 2021

Can you fix the double indentation in the if bodies?

Copy link
Member Author

@kevinrushforth kevinrushforth Mar 25, 2021

Sure, as long as I am there, I'll do that.

break;
case ']':
--bracketCount;
assertTrue("Too many closing brackets: " + str, bracketCount >= 0);
Copy link
Collaborator

@nlisker nlisker Mar 25, 2021

This test can fail due to a malformed toString result in the node (getIntersectedNode()), which I would think is outside the scope of this test. In practice, this test's result is dependent on what node I choose to test.

Shouldn't we be testing the structure of the string and not its contents?

Copy link
Member Author

@kevinrushforth kevinrushforth Mar 25, 2021

On the one hand, I can see your point that it's somewhat tangential that Rectangle has matched brackets, but you could say the same about the Point3D. Here is the result of MouseEvent.toString for the test:

MouseEvent [source = javafx.event.Event$$Lambda$110/0x0000000800c52fa8@461111c0,
target = javafx.event.Event$$Lambda$110/0x0000000800c52fa8@461111c0, eventType = MOUSE_PRESSED,
consumed = false, x = 18.0, y = 27.0, z = 150.0, button = PRIMARY, primaryButtonDown,
pickResult = PickResult [node = Rectangle[x=0.0, y=0.0, width=0.0, height=0.0, fill=0x000000ff],
point = Point3D [x = 15.0, y = 25.0, z = 100.0], distance = 33.0]]

The test would be more complicated if it were changed to ignore the results of the toString() of both the intersected node and the point. If I were to go down this path, I would likely just change it to do match a regex of "^MouseEvent \[.*PickResult \[.*\]\]$", which would be simple. Do you think it's worth it?

Maybe instead I could add a comment that this test checks for matching brackets in the entire composed string returned by MouseEvent::toString, including PickResult::toString, which in turn includes Node::toString for the intersected node?

Copy link
Collaborator

@nlisker nlisker Mar 25, 2021

I don't think it matters too much, but a change in any of the classes used here could break this test, which is a bit off. I will be satisfied with a comment warning about this case so if it breaks it will be easy to see where the problem is.

@nlisker
Copy link
Collaborator

@nlisker nlisker commented Mar 25, 2021

By the way, this class could easily be converted to a record, and that would take care of the toString and other ceremonies. I'm not sure it's a backwards compatible change, though.

@kevinrushforth
Copy link
Member Author

@kevinrushforth kevinrushforth commented Mar 25, 2021

Converting an existing class to a Record wouldn't be backward compatible (not to mention we can't use them yet). It wouldn't help for the Node::toString portion in any case.

I'll add the comment and send out a new version.

@openjdk openjdk bot removed the ready label Mar 25, 2021
@openjdk openjdk bot added the ready label Mar 25, 2021
@kevinrushforth
Copy link
Member Author

@kevinrushforth kevinrushforth commented Mar 31, 2021

/integrate

@openjdk openjdk bot closed this Mar 31, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Mar 31, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 31, 2021

@kevinrushforth Since your change was applied there have been 2 commits pushed to the master branch:

  • d80b8ad: 8264501: UIWebView for iOS is deprecated
  • ed5cfe7: 8211362: Restrict export of libjpeg symbols from libjavafx_iio.so

Your commit was automatically rebased without conflicts.

Pushed as commit f3e27a0.

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

@kevinrushforth kevinrushforth deleted the 8264162-pickresult-string branch Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants