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

    https://github.com/apache/flink/pull/3391#discussion_r103203962
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/BootstrapTools.java
 ---
    @@ -80,44 +79,23 @@ public static ActorSystem startActorSystem(
                        throw new IllegalArgumentException("Invalid port range 
definition: " + portRangeDefinition);
                }
     
    -           while (portsIterator.hasNext()) {
    -                   // first, we check if the port is available by opening 
a socket
    -                   // if the actor system fails to start on the port, we 
try further
    -                   ServerSocket availableSocket = 
NetUtils.createSocketFromPorts(
    -                           portsIterator,
    -                           new NetUtils.SocketFactory() {
    -                                   @Override
    -                                   public ServerSocket createSocket(int 
port) throws IOException {
    -                                           return new ServerSocket(port);
    -                                   }
    -                           });
    -
    -                   int port;
    -                   if (availableSocket == null) {
    -                           throw new BindException("Unable to allocate 
further port in port range: " + portRangeDefinition);
    -                   } else {
    -                           port = availableSocket.getLocalPort();
    +           return NetUtils.createServerFromPorts(listeningAddress, 
portsIterator, new NetUtils.ServerFactory<ActorSystem>() {
    +                   @Override
    +                   public ActorSystem create(String address, int port) 
throws Exception {
                                try {
    -                                   availableSocket.close();
    -                           } catch (IOException ignored) {}
    -                   }
    -
    -                   try {
    -                           return startActorSystem(configuration, 
listeningAddress, port, logger);
    -                   }
    -                   catch (Exception e) {
    -                           // we can continue to try if this contains a 
netty channel exception
    -                           Throwable cause = e.getCause();
    -                           if (!(cause instanceof 
org.jboss.netty.channel.ChannelException ||
    -                                           cause instanceof 
java.net.BindException)) {
    -                                   throw e;
    -                           } // else fall through the loop and try the 
next port
    +                                   return startActorSystem(configuration, 
address, port, logger);
    +                           }
    +                           catch (Exception e) {
    +                                   Throwable cause = e.getCause();
    +                                   if (cause instanceof 
org.jboss.netty.channel.ChannelException ||
    +                                           cause instanceof 
java.net.BindException) {
    +                                           throw new 
BindException(e.getMessage());
    --- End diff --
    
    not good to throw away the stack trace of the cause.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to