GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Try making the DatagramMulticastTest less flaky (#15498) · netty/netty@ccdb178

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • testsuite/src/main/java/io/netty/testsuite/transport/socket
    • DatagramMulticastTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramMulticastTest.java‎

Copy file name to clipboardExpand all lines: testsuite/src/main/java/io/netty/testsuite/transport/socket/DatagramMulticastTest.java
+25-15Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import io.netty.bootstrap.Bootstrap;
1919
import io.netty.buffer.Unpooled;
20+
import io.netty.channel.ChannelFuture;
2021
import io.netty.channel.ChannelHandlerContext;
2122
import io.netty.channel.ChannelOption;
2223
import io.netty.channel.SimpleChannelInboundHandler;
@@ -81,25 +82,34 @@ public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception
8182
cb.option(ChannelOption.IP_MULTICAST_IF, iface);
8283
cb.option(ChannelOption.SO_REUSEADDR, true);
8384

84-
DatagramChannel sc = (DatagramChannel) sb.bind(newSocketAddress(iface)).sync().channel();
85-
assertEquals(iface, sc.config().getNetworkInterface());
86-
assertInterfaceAddress(iface, sc.config().getInterface());
85+
DatagramChannel sc = null;
8786

88-
InetSocketAddress addr = sc.localAddress();
89-
cb.localAddress(addr.getPort());
90-
91-
if (sc instanceof OioDatagramChannel) {
92-
// skip the test for OIO, as it fails because of
93-
// No route to host which makes no sense.
94-
// Maybe a JDK bug ?
95-
sc.close().awaitUninterruptibly();
96-
return;
97-
}
98-
DatagramChannel cc = (DatagramChannel) cb.bind().sync().channel();
87+
int attempts = 5;
88+
ChannelFuture clientFuture;
89+
do {
90+
if (sc != null) {
91+
sc.close().sync();
92+
}
93+
sc = (DatagramChannel) sb.bind(newSocketAddress(iface)).sync().channel();
94+
if (sc instanceof OioDatagramChannel) {
95+
// skip the test for OIO, as it fails because of
96+
// No route to host which makes no sense.
97+
// Maybe a JDK bug ?
98+
sc.close().awaitUninterruptibly();
99+
return;
100+
}
101+
assertEquals(iface, sc.config().getNetworkInterface());
102+
assertInterfaceAddress(iface, sc.config().getInterface());
103+
104+
InetSocketAddress addr = sc.localAddress();
105+
cb.localAddress(addr.getPort());
106+
clientFuture = cb.bind().await();
107+
} while (!clientFuture.isSuccess() && --attempts > 0);
108+
DatagramChannel cc = (DatagramChannel) clientFuture.sync().channel();
99109
assertEquals(iface, cc.config().getNetworkInterface());
100110
assertInterfaceAddress(iface, cc.config().getInterface());
101111

102-
InetSocketAddress groupAddress = SocketUtils.socketAddress(groupAddress(), addr.getPort());
112+
InetSocketAddress groupAddress = SocketUtils.socketAddress(groupAddress(), sc.localAddress().getPort());
103113

104114
cc.joinGroup(groupAddress, iface).sync();
105115

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.