You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/01/31 11:32:25 UTC
svn commit: r1781061 -
/tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java
Author: markt
Date: Tue Jan 31 11:32:25 2017
New Revision: 1781061
URL: http://svn.apache.org/viewvc?rev=1781061&view=rev
Log:
Don't rely on localhost
Modified:
tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java
Modified: tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java?rev=1781061&r1=1781060&r2=1781061&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java Tue Jan 31 11:32:25 2017
@@ -35,7 +35,6 @@ import org.junit.Test;
public class TestSocketServerAnyLocalAddress {
private boolean nativeLibraryPresent = false;
- private int port = 0;
private long serverSocket = 0;
private long clientSocket = 0;
@@ -64,8 +63,6 @@ public class TestSocketServerAnyLocalAdd
if (!OS.IS_UNIX) {
Socket.optSet(serverSocket, Socket.APR_SO_REUSEADDR, 1);
}
- long localAddress = Address.get(Socket.APR_LOCAL, serverSocket);
- port = Address.getInfo(localAddress).port;
}
@@ -88,7 +85,7 @@ public class TestSocketServerAnyLocalAdd
@Test
public void testWithClient() throws Exception {
/* Start the client that connects to the server */
- Client client = new Client(serverSocket, port);
+ Client client = new Client(serverSocket);
client.start();
boolean running = true;
@@ -127,11 +124,9 @@ public class TestSocketServerAnyLocalAdd
private static class Client extends java.lang.Thread {
private final long serverSocket;
- private final int port;
- public Client(long serverSocket, int port) throws Exception {
+ public Client(long serverSocket) throws Exception {
this.serverSocket = serverSocket;
- this.port = port;
}
@Override
@@ -152,8 +147,9 @@ public class TestSocketServerAnyLocalAdd
throw new Exception("Read wrong data");
}
- /* Now use localhost to write 'E' */
- sock = new java.net.Socket("localhost", port);
+ sock = new java.net.Socket();
+ sock.connect(connectAddress, 10000);
+ sock.setSoTimeout(10000);
ou = sock.getOutputStream();
ou.write('E');
ou.flush();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org