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

ASF GitHub Bot commented on STORM-1523:
---------------------------------------

Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1073#discussion_r51916654
  
    --- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
    @@ -1374,5 +1393,29 @@ public static RuntimeException 
wrapInRuntime(Exception e){
                 return new RuntimeException(e);
             }
         }
    +
    +    public static int getAvailablePort(Integer port) {
    +        Integer localPort = null;
    +        ServerSocket socket = null;
    +        try {
    +            socket = new ServerSocket(port);
    +            localPort = socket.getLocalPort();
    +        } catch (IOException exp) {
    +            getAvailablePort(0);
    +        } finally {
    +            try {
    +                if(socket != null) {
    +                    socket.close();
    +                }
    +            } catch (IOException exp) {
    +                LOG.error("Socket Exception", exp);
    +            }
    +        }
    +        return localPort;
    +    }
    +
    +    public static int getAvailablePort() {
    +            return getAvailablePort(0);
    --- End diff --
    
    Indentation looks off here.


> Translate Available Ports task in util.java
> -------------------------------------------
>
>                 Key: STORM-1523
>                 URL: https://issues.apache.org/jira/browse/STORM-1523
>             Project: Apache Storm
>          Issue Type: Sub-task
>          Components: storm-core
>            Reporter: Sanket Reddy
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to