You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2022/03/01 10:24:11 UTC

[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3969: ARTEMIS-3699 expose ephemeral port on NettyAcceptor

gemmellr commented on a change in pull request #3969:
URL: https://github.com/apache/activemq-artemis/pull/3969#discussion_r816627195



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
##########
@@ -715,6 +717,9 @@ private void startServerChannels() {
          Channel serverChannel = null;
          try {
             serverChannel = bootstrap.bind(address).syncUninterruptibly().channel();
+            if (port == 0 && serverChannel.localAddress() instanceof InetSocketAddress) {
+               ephemeralPort = ((InetSocketAddress)serverChannel.localAddress()).getPort();
+            }

Review comment:
       I'd suggest going with 'actualPort' and setting it in each case (port== 0 or not), thus having the getter always return the port value, whether it is a specified non-0 port or a port-0 selected-on-bind value.
   
   That way the method is always useful, even in case of a configured port to get the value (as opposed to trying the config retrieval sequence from the JIRA), and it wont require you to essentially already know in advance of calling whether the acceptor had one configured or selected on bind.

##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
##########
@@ -241,6 +241,8 @@
 
    private volatile Object providerAgnosticSslContext;
 
+   private int ephemeralPort = 0;

Review comment:
       This should probably be volatile for safety since it seems it will have to be accessed by a different thread in actual use (most likely straight after setting), so unless there is an explicit barrier between them somewhere it would be unreliable otherwise.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org