Skip to content

Commit

Permalink
8269657: Test java/nio/channels/DatagramChannel/Loopback.java failed:…
Browse files Browse the repository at this point in the history
… Unexpected message

Reviewed-by: dfuchs
  • Loading branch information
SendaoYan authored and dfuch committed Jun 28, 2024
1 parent 99d2bbf commit c798316
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/jdk/java/nio/channels/DatagramChannel/Loopback.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -118,7 +118,8 @@ static void test(ProtocolFamily family, InetAddress group, NetworkInterface ni)

// send datagram to multicast group
System.out.format("send %s -> %s%n", dc.getLocalAddress(), target);
ByteBuffer src = ByteBuffer.wrap("hello".getBytes("UTF-8"));
String str = "hello " + System.nanoTime();
ByteBuffer src = ByteBuffer.wrap(str.getBytes("UTF-8"));
dc.send(src, target);

// receive datagram sent to multicast group
Expand All @@ -142,6 +143,7 @@ static void test(ProtocolFamily family, InetAddress group, NetworkInterface ni)
System.out.format("send %s -> %s%n", dc.getLocalAddress(), target);
src.clear();
dc.send(src, target);
src.flip();

// test that we don't receive the datagram sent to multicast group
dc.configureBlocking(false);
Expand All @@ -157,10 +159,16 @@ static void test(ProtocolFamily family, InetAddress group, NetworkInterface ni)
} else {
sel.selectedKeys().clear();
SocketAddress sender = dc.receive(dst);
if (src.mismatch(dst) != -1) {
System.out.println("src: " + src + "not equal to dst: " + dst);
dst.clear();
continue;
}
if (sender != null) {
System.out.format("received %s from %s%n", dst, sender);
senderPort = ((InetSocketAddress) sender).getPort();
assertTrue(senderPort != localPort, "Unexpected message");
assertTrue(senderPort != localPort,
"Unexpected message: localPort=" + localPort);
}
}
}
Expand Down

7 comments on commit c798316

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@sendaoYan
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk:jdk23

@openjdk
Copy link

@openjdk openjdk bot commented on c798316 Jun 28, 2024

Choose a reason for hiding this comment

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

@sendaoYan the backport was successfully created on the branch backport-sendaoYan-c798316b-jdk23 in my personal fork of openjdk/jdk. To create a pull request with this backport targeting openjdk/jdk:jdk23, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c798316b from the openjdk/jdk repository.

The commit being backported was authored by SendaoYan on 28 Jun 2024 and was reviewed by Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk:

$ git fetch https://github.com/openjdk-bots/jdk.git backport-sendaoYan-c798316b-jdk23:backport-sendaoYan-c798316b-jdk23
$ git checkout backport-sendaoYan-c798316b-jdk23
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk.git backport-sendaoYan-c798316b-jdk23

@sendaoYan
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@sendaoYan
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on c798316 Jul 16, 2024

Choose a reason for hiding this comment

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

@sendaoYan the backport was successfully created on the branch backport-sendaoYan-c798316b-master in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c798316b from the openjdk/jdk repository.

The commit being backported was authored by SendaoYan on 28 Jun 2024 and was reviewed by Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-sendaoYan-c798316b-master:backport-sendaoYan-c798316b-master
$ git checkout backport-sendaoYan-c798316b-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-sendaoYan-c798316b-master

@openjdk
Copy link

@openjdk openjdk bot commented on c798316 Jul 16, 2024

Choose a reason for hiding this comment

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

@sendaoYan the backport was successfully created on the branch backport-sendaoYan-c798316b-master in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit c798316b from the openjdk/jdk repository.

The commit being backported was authored by SendaoYan on 28 Jun 2024 and was reviewed by Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-sendaoYan-c798316b-master:backport-sendaoYan-c798316b-master
$ git checkout backport-sendaoYan-c798316b-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-sendaoYan-c798316b-master

Please sign in to comment.