1
1
/*
2
- * Copyright (c) 2019, 2020 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2019, 2024 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -118,7 +118,8 @@ static void test(ProtocolFamily family, InetAddress group, NetworkInterface ni)
118
118
119
119
// send datagram to multicast group
120
120
System .out .format ("send %s -> %s%n" , dc .getLocalAddress (), target );
121
- ByteBuffer src = ByteBuffer .wrap ("hello" .getBytes ("UTF-8" ));
121
+ String str = "hello " + System .nanoTime ();
122
+ ByteBuffer src = ByteBuffer .wrap (str .getBytes ("UTF-8" ));
122
123
dc .send (src , target );
123
124
124
125
// receive datagram sent to multicast group
@@ -142,6 +143,7 @@ static void test(ProtocolFamily family, InetAddress group, NetworkInterface ni)
142
143
System .out .format ("send %s -> %s%n" , dc .getLocalAddress (), target );
143
144
src .clear ();
144
145
dc .send (src , target );
146
+ src .flip ();
145
147
146
148
// test that we don't receive the datagram sent to multicast group
147
149
dc .configureBlocking (false );
@@ -157,10 +159,16 @@ static void test(ProtocolFamily family, InetAddress group, NetworkInterface ni)
157
159
} else {
158
160
sel .selectedKeys ().clear ();
159
161
SocketAddress sender = dc .receive (dst );
162
+ if (src .mismatch (dst ) != -1 ) {
163
+ System .out .println ("src: " + src + "not equal to dst: " + dst );
164
+ dst .clear ();
165
+ continue ;
166
+ }
160
167
if (sender != null ) {
161
168
System .out .format ("received %s from %s%n" , dst , sender );
162
169
senderPort = ((InetSocketAddress ) sender ).getPort ();
163
- assertTrue (senderPort != localPort , "Unexpected message" );
170
+ assertTrue (senderPort != localPort ,
171
+ "Unexpected message: localPort=" + localPort );
164
172
}
165
173
}
166
174
}
0 commit comments