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

    https://github.com/apache/brooklyn-server/pull/276#discussion_r72585710
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/util/core/BrooklynNetworkUtils.java ---
    @@ -39,4 +43,22 @@ public static InetAddress getLocalhostInetAddress() {
                     Networking.getLocalHost()), InetAddress.class);
         }
     
    +    // TODO it does not add adjacent intervals: {[22, 22], [23, 23]} is 
not merged to {[22, 23]}
    +    public static RangeSet<Integer> portRulesToRanges(Collection<String> 
portRules) {
    +        RangeSet<Integer> result = TreeRangeSet.create();
    +        for (String portRule : portRules) {
    +            if (portRule.contains("-")) {
    +                String[] fromTo = portRule.split("-");
    +                assert fromTo.length == 2;
    --- End diff --
    
    Don't use `assert` for validating user input. Instead we'd want to throw a 
nicer `IllegalArgumentException` to tell the caller that they passed in the 
wrong input.
    
    Only use `assert` when it's about the internal invariants of a class (e.g. 
validating args in private methods, etc).


---
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