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

8266250: WebSocketTest and WebSocketProxyTest call assertEquals(List<byte[]>, List<byte[]>) #3776

Closed
wants to merge 5 commits into from

Conversation

@dfuch
Copy link
Member

@dfuch dfuch commented Apr 28, 2021

Please find here an almost trivial test fix that should improve diagnostic in case of failures.
It also avoids relying on an unspecified behavior of Assert.assertEquals.


Progress

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

Issue

  • JDK-8266250: WebSocketTest and WebSocketProxyTest call assertEquals(List<byte[]>, List<byte[]>)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3776

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Apr 28, 2021

👋 Welcome back dfuchs! 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.

Loading

@openjdk openjdk bot added the rfr label Apr 28, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 28, 2021

@dfuch The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

Loading

@openjdk openjdk bot added the net label Apr 28, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Apr 28, 2021

Loading

@pavelrappo
Copy link
Member

@pavelrappo pavelrappo commented Apr 28, 2021

It also avoids relying on an unspecified behavior of Assert.assertEquals.

Which behavior is that? If I recall correctly, the test was written for TestNG 6.9.5, which provides a method to compare collections.

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented Apr 29, 2021

Mailing list message from Daniel Fuchs on net-dev:

On 28/04/2021 23:51, Pavel Rappo wrote:

On Wed, 28 Apr 2021 21:22:23 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

It also avoids relying on an unspecified behavior of `Assert.assertEquals`.

Which behavior is that? If I recall correctly, the test was written for TestNG 6.9.5, which provides a [method to compare collections](https://github.com/cbeust/testng/blob/ef2d1199abff4e1b8fa4b1148c1314e776d7a044/src/main/java/org/testng/Assert.java#L508-L517).

Exactly - that API specification doesn't say whether elements
that are arrays will be compared using shallow equals or deep
equals.

The latest version of TestNG seems to have changed how elements
in collections are compared:
https://github.com/cbeust/testng/blob/b60a1a13d274e5991f357d3ad1b41ce16c53de64/core/src/main/java/org/testng/Assert.java#L143

-- daniel

Loading

1 similar comment
@mlbridge
Copy link

@mlbridge mlbridge bot commented Apr 29, 2021

Mailing list message from Daniel Fuchs on net-dev:

On 28/04/2021 23:51, Pavel Rappo wrote:

On Wed, 28 Apr 2021 21:22:23 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

It also avoids relying on an unspecified behavior of `Assert.assertEquals`.

Which behavior is that? If I recall correctly, the test was written for TestNG 6.9.5, which provides a [method to compare collections](https://github.com/cbeust/testng/blob/ef2d1199abff4e1b8fa4b1148c1314e776d7a044/src/main/java/org/testng/Assert.java#L508-L517).

Exactly - that API specification doesn't say whether elements
that are arrays will be compared using shallow equals or deep
equals.

The latest version of TestNG seems to have changed how elements
in collections are compared:
https://github.com/cbeust/testng/blob/b60a1a13d274e5991f357d3ad1b41ce16c53de64/core/src/main/java/org/testng/Assert.java#L143

-- daniel

Loading

@pavelrappo
Copy link
Member

@pavelrappo pavelrappo commented Apr 29, 2021

Exactly - that API specification doesn't say whether elements
that are arrays will be compared using shallow equals or deep
equals.

Fair enough.

Since you are here, consider further improving diagnosability. The failed comparison should provide more info.
Currently, assertEquals short-circuits by reporting only one property of the lists that differs. If the lists are of different size, it's the size that is reported. If the lists are of the same size, it's the leftmost non-equal element that is reported, if any. In either case, there might be a lot of info missing. Given that the comparables are relatively small, it makes sense to print them out in full.

Loading

@dfuch
Copy link
Member Author

@dfuch dfuch commented Apr 29, 2021

@pavelrappo: done.

Loading

var problem = actual.equals(expected) ? "match" : "differ";
return "%s and %s %s".formatted(actual, expected, problem);
Copy link
Member

@pavelrappo pavelrappo Apr 29, 2021

Choose a reason for hiding this comment

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

I would rename "problem" to more neutral "message" or "description". Ditto in the other file.

Loading

Copy link
Member Author

@dfuch dfuch Apr 29, 2021

Choose a reason for hiding this comment

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

Done.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Apr 29, 2021

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

8266250: WebSocketTest and WebSocketProxyTest call assertEquals(List<byte[]>, List<byte[]>)

Reviewed-by: prappo

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

  • 294347b: 8265918: java/io/Console/CharsetTest.java failed with "expect: spawn id exp6 not open"
  • 84b52db: 8265666: Enable AIX build platform to make external debug symbols
  • dd8286e: 8198616: java/awt/Focus/6378278/InputVerifierTest.java fails on mac
  • 5574922: 8266284: ProblemList java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java

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.

Loading

@openjdk openjdk bot added the ready label Apr 29, 2021
@dfuch
Copy link
Member Author

@dfuch dfuch commented Apr 29, 2021

/integrate

Loading

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

@openjdk openjdk bot commented Apr 29, 2021

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

  • 5f15666: 8266078: Reader.read(CharBuffer) advances Reader position for read-only Charbuffers
  • 2a03739: 8266014: Regression brought by optimization done with JDK-4926314
  • 6bb71d9: 8264762: ByteBuffer.byteOrder(BIG_ENDIAN).asXBuffer.put(Xarray) and ByteBuffer.byteOrder(nativeOrder()).asXBuffer.put(Xarray) are slow
  • f0f6b0d: 8266027: The diamond finder does not find diamond candidates in field initializers
  • 8072ea5: 8238173: jshell - switch statement with a single default not return cause syntax error
  • c76ce28: 8265842: G1: Introduce API to run multiple separate tasks in a single gangtask
  • 294347b: 8265918: java/io/Console/CharsetTest.java failed with "expect: spawn id exp6 not open"
  • 84b52db: 8265666: Enable AIX build platform to make external debug symbols
  • dd8286e: 8198616: java/awt/Focus/6378278/InputVerifierTest.java fails on mac
  • 5574922: 8266284: ProblemList java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java

Your commit was automatically rebased without conflicts.

Pushed as commit 01415f3.

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

Loading

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