Skip to content

Commit 26fb73d

Browse files
authored
Merge pull request #1819 from fl4via/UNDERTOW-1874
[UNDERTOW-1874] Revert fix so we can investigate failures
2 parents c5d6800 + 99751de commit 26fb73d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

servlet/src/test/java/io/undertow/servlet/test/ProxyForwardedTestCase.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import jakarta.servlet.ServletException;
4545
import java.io.IOException;
4646
import java.net.InetSocketAddress;
47+
import java.net.Socket;
4748
import java.util.Arrays;
4849
import java.util.HashMap;
4950
import java.util.Map;
@@ -55,9 +56,11 @@
5556
@RunWith(DefaultServer.class)
5657
@ProxyIgnore
5758
public class ProxyForwardedTestCase {
59+
protected static int PORT;
5860

5961
@BeforeClass
6062
public static void setup() throws ServletException {
63+
PORT = DefaultServer.getHostPort("default");
6164
final PathHandler root = new PathHandler();
6265
final ServletContainer container = ServletContainer.Factory.newInstance();
6366

@@ -95,12 +98,13 @@ public void testForwardedHandler() throws IOException {
9598
HttpEntity entity = result.getEntity();
9699
String results = EntityUtils.toString(entity);
97100
Map<String, String> map = convertWithStream(results);
98-
InetSocketAddress serverAddress = DefaultServer.getDefaultServerAddress();
101+
Socket socket = new Socket();
102+
socket.connect(new InetSocketAddress(DefaultServer.getHostAddress(), PORT));
99103

100104
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
101-
Assert.assertEquals(serverAddress.getAddress().getHostAddress(), map.get(GenericServletConstants.LOCAL_ADDR));
102-
Assert.assertEquals(serverAddress.getAddress().getHostName(), map.get(GenericServletConstants.LOCAL_NAME));
103-
Assert.assertEquals(serverAddress.getPort(), Integer.parseInt(map.get(GenericServletConstants.LOCAL_PORT)));
105+
Assert.assertEquals(socket.getLocalAddress().getHostAddress(), map.get(GenericServletConstants.LOCAL_ADDR));
106+
Assert.assertEquals(socket.getLocalAddress().getHostName(), map.get(GenericServletConstants.LOCAL_NAME));
107+
Assert.assertEquals(PORT, Integer.parseInt(map.get(GenericServletConstants.LOCAL_PORT)));
104108
Assert.assertEquals("192.0.2.10", map.get(GenericServletConstants.SERVER_NAME));
105109
Assert.assertEquals("8888", map.get(GenericServletConstants.SERVER_PORT));
106110
Assert.assertEquals("192.0.2.43", map.get(GenericServletConstants.REMOTE_ADDR));

servlet/src/test/java/io/undertow/servlet/test/ProxyXForwardedTestCase.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import jakarta.servlet.ServletException;
4545
import java.io.IOException;
4646
import java.net.InetSocketAddress;
47+
import java.net.Socket;
4748
import java.util.Arrays;
4849
import java.util.HashMap;
4950
import java.util.Map;
@@ -55,9 +56,11 @@
5556
@RunWith(DefaultServer.class)
5657
@ProxyIgnore
5758
public class ProxyXForwardedTestCase {
59+
protected static int PORT;
5860

5961
@BeforeClass
6062
public static void setup() throws ServletException {
63+
PORT = DefaultServer.getHostPort("default");
6164
final PathHandler root = new PathHandler();
6265
final ServletContainer container = ServletContainer.Factory.newInstance();
6366

@@ -93,12 +96,13 @@ public void testProxyPeerHandler() throws IOException, ServletException {
9396
HttpEntity entity = result.getEntity();
9497
String results = EntityUtils.toString(entity);
9598
Map<String, String> map = convertWithStream(results);
96-
InetSocketAddress serverAddress = DefaultServer.getDefaultServerAddress();
99+
Socket socket = new Socket();
100+
socket.connect(new InetSocketAddress(DefaultServer.getHostAddress(), PORT));
97101

98102
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
99-
Assert.assertEquals(serverAddress.getAddress().getHostAddress(), map.get(GenericServletConstants.LOCAL_ADDR));
100-
Assert.assertEquals(serverAddress.getAddress().getHostName(), map.get(GenericServletConstants.LOCAL_NAME));
101-
Assert.assertEquals(serverAddress.getPort(), Integer.parseInt(map.get(GenericServletConstants.LOCAL_PORT)));
103+
Assert.assertEquals(socket.getLocalAddress().getHostAddress(), map.get(GenericServletConstants.LOCAL_ADDR));
104+
Assert.assertEquals(socket.getLocalAddress().getHostName(), map.get(GenericServletConstants.LOCAL_NAME));
105+
Assert.assertEquals(PORT, Integer.parseInt(map.get(GenericServletConstants.LOCAL_PORT)));
102106
Assert.assertEquals("192.0.2.10", map.get(GenericServletConstants.SERVER_NAME));
103107
Assert.assertEquals("8888", map.get(GenericServletConstants.SERVER_PORT));
104108
Assert.assertEquals("192.0.2.43", map.get(GenericServletConstants.REMOTE_ADDR));

0 commit comments

Comments
 (0)