You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2013/07/02 15:25:05 UTC

git commit: updated refs/heads/master-6-17-stable to df2b3d0

Updated Branches:
  refs/heads/master-6-17-stable 71d7012d5 -> df2b3d0ed


CLOUDSTACK-3198: HashSet used for storing ACL rules doesn't maintain the order. Added rules directly to result string array after sorting.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/df2b3d0e
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/df2b3d0e
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/df2b3d0e

Branch: refs/heads/master-6-17-stable
Commit: df2b3d0ed8f2eebb3e8d2b8b14da0e404503507c
Parents: 71d7012
Author: Kishan Kavala <ki...@cloud.com>
Authored: Tue Jul 2 18:47:09 2013 +0530
Committer: Kishan Kavala <ki...@cloud.com>
Committed: Tue Jul 2 18:54:38 2013 +0530

----------------------------------------------------------------------
 .../cloud/agent/api/routing/SetNetworkACLCommand.java  | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/df2b3d0e/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
index d876c61..236e8ea 100644
--- a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java
@@ -43,16 +43,16 @@ public class SetNetworkACLCommand extends NetworkElementCommand{
         return rules;
     }
     public String[][] generateFwRules() {
-        String [][] result = new String [2][];
-        Set<String> toAdd = new HashSet<String>();
         List<NetworkACLTO> aclList = Arrays.asList(rules);
         Collections.sort(aclList, new Comparator<NetworkACLTO>() {
             @Override
             public int compare(NetworkACLTO acl1, NetworkACLTO acl2) {
-                return acl1.getNumber() > acl2.getNumber() ? 1 : -1;
+                return acl1.getNumber() < acl2.getNumber() ? 1 : -1;
             }
         });
 
+        String [][] result = new String [2][aclList.size()];
+        int i = 0;
         for (NetworkACLTO aclTO: aclList) {
         /*  example  :  Ingress:tcp:80:80:0.0.0.0/0:ACCEPT:,Egress:tcp:220:220:0.0.0.0/0:DROP:,
          *  each entry format      Ingress/Egress:protocol:start port: end port:scidrs:action:
@@ -64,7 +64,7 @@ public class SetNetworkACLCommand extends NetworkElementCommand{
                 /* This entry is added just to make sure atleast there will one entry in the list to get the ipaddress */
                 sb.append(aclTO.getTrafficType().toString()).append(":reverted:0:0:0:");
                 String aclRuleEntry = sb.toString();
-                toAdd.add(aclRuleEntry);
+                result[0][i++] = aclRuleEntry;
                 continue;
             }
 
@@ -91,11 +91,8 @@ public class SetNetworkACLCommand extends NetworkElementCommand{
             }
             sb.append(":").append(aclTO.getAction()).append(":");
             String aclRuleEntry = sb.toString();
-
-            toAdd.add(aclRuleEntry);
-
+            result[0][i++] = aclRuleEntry;
         }
-        result[0] = toAdd.toArray(new String[toAdd.size()]);
 
         return result;
     }