Skip to content

Commit

Permalink
8241550: [macOS] SSLSocketImpl/ReuseAddr.java failed due to "BindExce…
Browse files Browse the repository at this point in the history
…ption: Address already in use"

Reviewed-by: jpai, mullan
  • Loading branch information
dfuch committed May 24, 2024
1 parent f16265d commit 6a35311
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/jdk/sun/security/ssl/SSLSocketImpl/ReuseAddr.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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 @@ -34,9 +34,12 @@
*/

import java.net.ServerSocket;
import java.net.BindException;

public class ReuseAddr extends SSLSocketTemplate {

private static final int MAX_ATTEMPTS = 3;

@Override
protected void doServerSide() throws Exception {
super.doServerSide();
Expand All @@ -50,6 +53,21 @@ protected void doServerSide() throws Exception {
}

public static void main(String[] args) throws Exception {
new ReuseAddr().run();
for (int i=1 ; i <= MAX_ATTEMPTS; i++) {
try {
new ReuseAddr().run();
System.out.println("Test succeeded at attempt " + i);
break;
} catch (BindException x) {
System.out.println("attempt " + i + " failed: " + x);
if (i == MAX_ATTEMPTS) {
String msg = "Could not succeed after " + i + " attempts";
System.err.println(msg);
throw new AssertionError("Failed to reuse address: " + msg, x);
} else {
System.out.println("Retrying...");
}
}
}
}
}

0 comments on commit 6a35311

Please sign in to comment.