diff --git a/container/spi/src/main/java/org/jboss/modcluster/container/Connector.java b/container/spi/src/main/java/org/jboss/modcluster/container/Connector.java index 3ca29524..335d3df7 100644 --- a/container/spi/src/main/java/org/jboss/modcluster/container/Connector.java +++ b/container/spi/src/main/java/org/jboss/modcluster/container/Connector.java @@ -73,9 +73,10 @@ public String toString() { void setAddress(InetAddress address); /** - * Returns the port on which this connector operates. + * Returns the port on which this connector operates. Note that the implementations need to account for any form + * of external port mapping or port offsetting that might have an effect on the configured port. * - * @return a port number + * @return a port number on which this connector operates */ int getPort(); diff --git a/container/tomcat-10.1/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java b/container/tomcat-10.1/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java index c9c69e09..bc30d4a2 100644 --- a/container/tomcat-10.1/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java +++ b/container/tomcat-10.1/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java @@ -78,7 +78,7 @@ public void setAddress(InetAddress address) { @Override public int getPort() { - return (this.externalPort == null) ? this.connector.getPort() : this.externalPort; + return (this.externalPort == null) ? this.connector.getPortWithOffset() : this.externalPort; } @Override @@ -112,7 +112,7 @@ public int hashCode() { @Override public String toString() { InetAddress address = this.getAddress(); - return String.format("%s://%s:%d", this.getType(), (address != null) ? address.getHostAddress() : "", this.connector.getPort()); + return String.format("%s://%s:%d", this.getType(), (address != null) ? address.getHostAddress() : "", this.connector.getPortWithOffset()); } /** diff --git a/container/tomcat-8.5/src/main/java/org/jboss/modcluster/container/tomcat/SingleServiceServer.java b/container/tomcat-8.5/src/main/java/org/jboss/modcluster/container/tomcat/SingleServiceServer.java index 104e1058..a69a911b 100644 --- a/container/tomcat-8.5/src/main/java/org/jboss/modcluster/container/tomcat/SingleServiceServer.java +++ b/container/tomcat-8.5/src/main/java/org/jboss/modcluster/container/tomcat/SingleServiceServer.java @@ -76,13 +76,13 @@ public int getPortOffset() { } @Override - public void setPortOffset(int i) { + public void setPortOffset(int portOffset) { throw new IllegalStateException(); } @Override public int getPortWithOffset() { - return this.service.getServer().getPort(); + return this.service.getServer().getPortWithOffset(); } @Override diff --git a/container/tomcat-8.5/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java b/container/tomcat-8.5/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java index c9c69e09..bc30d4a2 100644 --- a/container/tomcat-8.5/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java +++ b/container/tomcat-8.5/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java @@ -78,7 +78,7 @@ public void setAddress(InetAddress address) { @Override public int getPort() { - return (this.externalPort == null) ? this.connector.getPort() : this.externalPort; + return (this.externalPort == null) ? this.connector.getPortWithOffset() : this.externalPort; } @Override @@ -112,7 +112,7 @@ public int hashCode() { @Override public String toString() { InetAddress address = this.getAddress(); - return String.format("%s://%s:%d", this.getType(), (address != null) ? address.getHostAddress() : "", this.connector.getPort()); + return String.format("%s://%s:%d", this.getType(), (address != null) ? address.getHostAddress() : "", this.connector.getPortWithOffset()); } /** diff --git a/container/tomcat-9.0/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java b/container/tomcat-9.0/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java index c9c69e09..bc30d4a2 100644 --- a/container/tomcat-9.0/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java +++ b/container/tomcat-9.0/src/main/java/org/jboss/modcluster/container/tomcat/TomcatConnector.java @@ -78,7 +78,7 @@ public void setAddress(InetAddress address) { @Override public int getPort() { - return (this.externalPort == null) ? this.connector.getPort() : this.externalPort; + return (this.externalPort == null) ? this.connector.getPortWithOffset() : this.externalPort; } @Override @@ -112,7 +112,7 @@ public int hashCode() { @Override public String toString() { InetAddress address = this.getAddress(); - return String.format("%s://%s:%d", this.getType(), (address != null) ? address.getHostAddress() : "", this.connector.getPort()); + return String.format("%s://%s:%d", this.getType(), (address != null) ? address.getHostAddress() : "", this.connector.getPortWithOffset()); } /**