[ 
https://issues.apache.org/jira/browse/THRIFT-2188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18112783#comment-18112783
 ] 

Sylwester Lachiewicz edited comment on THRIFT-2188 at 9/8/26 1:45 PM:
----------------------------------------------------------------------

{{getPort()}} on 
[TNonblockingServerSocket.java:177|https://github.com/apache/thrift/blob/master/lib/java/src/main/java/org/apache/thrift/transport/TNonblockingServerSocket.java#L177]
 returns {{getLocalPort()}}, so binding to port 0 and reading the assigned port 
back works. Resolving as Fixed.


was (Author: slachiewicz):
TServerSocket binds via {{ServerSocketTransportArgs}} (port 0 yields an 
ephemeral port) and exposes {{getPort()}} to read the bound port back 
([lib/java/src/main/java/org/apache/thrift/transport/TServerSocket.java|https://github.com/apache/thrift/blob/master/lib/java/src/main/java/org/apache/thrift/transport/TServerSocket.java]
 line 177). Resolving as Fixed.

> allow java servers to bind to a random port, and get that port back out of 
> the transport
> ----------------------------------------------------------------------------------------
>
>                 Key: THRIFT-2188
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2188
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Library
>            Reporter: Eric C. Newton
>            Priority: Major
>         Attachments: patch-THRIFT-2188.patch
>
>
> The java TNonBlockingTransport allows you to bind to port zero, which allows 
> the OS to grab a random port.  However, it's not possible to learn what port 
> the OS decided to use.  I've attached a patch that exposes this information.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to