Thomas Vachuska
Committed by Gerrit Code Review

Fixed a defect where packet requests issued from different instances resulted in…

… 'redundant' packet requests due to different order of criteria serialization.

Change-Id: Ice8a0fea11b993fd4fc50b8093e02203fd76c772
...@@ -29,16 +29,21 @@ import org.onosproject.net.flow.criteria.Criteria; ...@@ -29,16 +29,21 @@ import org.onosproject.net.flow.criteria.Criteria;
29 import org.onosproject.net.flow.criteria.Criterion; 29 import org.onosproject.net.flow.criteria.Criterion;
30 30
31 import java.util.Collections; 31 import java.util.Collections;
32 +import java.util.Comparator;
32 import java.util.HashMap; 33 import java.util.HashMap;
33 import java.util.Map; 34 import java.util.Map;
34 import java.util.Objects; 35 import java.util.Objects;
35 import java.util.Set; 36 import java.util.Set;
37 +import java.util.TreeSet;
36 38
37 /** 39 /**
38 * Default traffic selector implementation. 40 * Default traffic selector implementation.
39 */ 41 */
40 public final class DefaultTrafficSelector implements TrafficSelector { 42 public final class DefaultTrafficSelector implements TrafficSelector {
41 43
44 + private static final Comparator<? super Criterion> TYPE_COMPARATOR =
45 + (c1, c2) -> c1.type().compareTo(c2.type());
46 +
42 private final Set<Criterion> criteria; 47 private final Set<Criterion> criteria;
43 48
44 private static final TrafficSelector EMPTY 49 private static final TrafficSelector EMPTY
...@@ -50,7 +55,9 @@ public final class DefaultTrafficSelector implements TrafficSelector { ...@@ -50,7 +55,9 @@ public final class DefaultTrafficSelector implements TrafficSelector {
50 * @param criteria criteria 55 * @param criteria criteria
51 */ 56 */
52 private DefaultTrafficSelector(Set<Criterion> criteria) { 57 private DefaultTrafficSelector(Set<Criterion> criteria) {
53 - this.criteria = ImmutableSet.copyOf(criteria); 58 + TreeSet<Criterion> elements = new TreeSet<>(TYPE_COMPARATOR);
59 + elements.addAll(criteria);
60 + this.criteria = ImmutableSet.copyOf(elements);
54 } 61 }
55 62
56 @Override 63 @Override
......