yanghua commented on a change in pull request #7263: [FLINK-11081] Support 
binding port range for REST server
URL: https://github.com/apache/flink/pull/7263#discussion_r240857598
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestServerEndpoint.java
 ##########
 @@ -181,14 +184,44 @@ protected void initChannel(SocketChannel ch) {
                                .channel(NioServerSocketChannel.class)
                                .childHandler(initializer);
 
-                       log.debug("Binding rest endpoint to {}:{}.", 
restBindAddress, restBindPort);
-                       final ChannelFuture channel;
-                       if (restBindAddress == null) {
-                               channel = bootstrap.bind(restBindPort);
-                       } else {
-                               channel = bootstrap.bind(restBindAddress, 
restBindPort);
+                       ChannelFuture channel;
+
+                       // parse port range definition and create port iterator
+                       Iterator<Integer> portsIterator;
+                       try {
+                               portsIterator = 
NetUtils.getPortRangeFromString(restBindPort);
+                       } catch (Exception e) {
 
 Review comment:
   `getPortRangeFromString ` also throws `IllegalConfigurationException` which 
is a unchecked exception defined in `flink-core`, so here we catch a general 
`Exception` and in the catch block then rethrow a unified 
`IllegalArgumentException `. This code style used in 
`BootstrapTools#startActorSystem`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to