Skip to content

Commit 9f165f0

Browse files
committed
spring-projectsGH-3666: Revise TcpNioConnectionTests.testMultiAccept() and testNoMultiAccept()
Seems like Windows socket connect to the loopback address fails sometimes because of a bug in the implementation of OpenJDK. Changing loopback addr with the actual IP addr seems to help.
1 parent bb91fd3 commit 9f165f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpNioConnectionTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.io.InputStream;
3535
import java.lang.reflect.Method;
3636
import java.net.ConnectException;
37+
import java.net.InetAddress;
3738
import java.net.ServerSocket;
3839
import java.net.Socket;
3940
import java.net.SocketTimeoutException;
@@ -63,7 +64,6 @@
6364

6465
import org.apache.commons.logging.Log;
6566
import org.apache.commons.logging.LogFactory;
66-
import org.junit.jupiter.api.Disabled;
6767
import org.junit.jupiter.api.Test;
6868
import org.junit.jupiter.api.TestInfo;
6969
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
@@ -839,13 +839,12 @@ public void testNoDelayOnClose() throws Exception {
839839
}
840840

841841
@Test
842-
@Disabled("Until https://github.com/spring-projects/spring-integration/issues/3666")
842+
// todo: env vars?
843843
public void testMultiAccept() throws InterruptedException, IOException {
844844
testMulti(true);
845845
}
846846

847847
@Test
848-
@Disabled("Until https://github.com/spring-projects/spring-integration/issues/3666")
849848
public void testNoMultiAccept() throws InterruptedException, IOException {
850849
testMulti(false);
851850
}
@@ -874,8 +873,9 @@ private void testMulti(boolean multiAccept) throws InterruptedException, IOExcep
874873
server.afterPropertiesSet();
875874
server.start();
876875
assertThat(serverReadyLatch.await(10, TimeUnit.SECONDS)).isTrue();
876+
InetAddress localHost = InetAddress.getLocalHost();
877877
for (int i = 0; i < 10; i++) {
878-
Socket socket = SocketFactory.getDefault().createSocket("localhost", server.getPort());
878+
Socket socket = SocketFactory.getDefault().createSocket(localHost, server.getPort());
879879
socket.getOutputStream().write("foo\r\n".getBytes());
880880
sockets.add(socket);
881881
}

0 commit comments

Comments
 (0)