Skip to content
Permalink
Browse files

WFCORE-3296 Ephemeral port number (port="0") should not be affected b…

…y port offset
  • Loading branch information
rhusar committed Apr 5, 2019
1 parent d1b0113 commit a1cf0e28111a4724634a985fffa0b8391e917b2d
@@ -113,7 +113,9 @@ public SocketBindingManager getSocketBindings() {

private int calculatePort() {
int port = this.port;
if (!isFixedPort) {
// 0 is a reserved port number indicating usage of system-allocated dynamic ports
// and thus port offset must not be applied
if (!isFixedPort && port != 0) {
port += socketBindings.getPortOffset();
}
return port;
@@ -265,11 +267,11 @@ public void setClientMappings(List<ClientMapping> clientMappings) {
}

/**
* Unlike the {@link #getPort()} method, this method takes into account the port offset, if the port
* is <i>not</i> a fixed port and returns the absolute port number which is the sum of the port offset
* and the (relative) port.
* Unlike the {@link #getPort()} method, this method takes into account the port offset, if the port is <i>not</i> a fixed
* port nor dynamically allocated ephemeral port (port number 0) and returns the absolute port number which is the sum of
* the port offset and the (relative) port.
*
* @return port number configured for this socket binding taking port-offset into account
* @return port number configured for this socket binding taking port-offset into account when appropriate
*/
public int getAbsolutePort() {
return calculatePort();
@@ -149,7 +149,8 @@ public void testPortOffsetZero() throws Exception {
Assert.assertEquals(8000, socketBinding.getSocketBindings().getPortOffset());
Assert.assertFalse("fixed port", socketBinding.isFixedPort());
Assert.assertEquals(0, socketBinding.getPort());
Assert.assertEquals(8000, socketBinding.getSocketAddress().getPort());
// Port 0 must not be affected by port-offset
Assert.assertEquals(0, socketBinding.getSocketAddress().getPort());
}

/**

0 comments on commit a1cf0e2

Please sign in to comment.
You can’t perform that action at this time.