Skip to content

Commit

Permalink
Fix issue where FeatureFlags were triggering listeners for non-changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Nov 16, 2020
1 parent f1e5206 commit 51d47ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -388,7 +389,7 @@ public static boolean groupsV1ForcedMigration() {
changes.put(key, Change.REMOVED);
} else if (newValue != oldValue && newValue instanceof Boolean) {
changes.put(key, (boolean) newValue ? Change.ENABLED : Change.DISABLED);
} else if (newValue != oldValue) {
} else if (!Objects.equals(oldValue, newValue)) {
changes.put(key, Change.CHANGED);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ public void computeChanges_generic() {
put("d", false);
put("g", 5);
put("h", 5);
put("i", new String("parker")); // Need to use new String to avoid interning string constants
put("j", "gwen");
}};

Map<String, Object> newMap = new HashMap<String, Object>() {{
Expand All @@ -399,6 +401,8 @@ public void computeChanges_generic() {
put("e", true);
put("f", false);
put("h", 7);
put("i", new String("parker")); // Need to use new String to avoid interning string constants
put("j", "stacy");
}};

Map<String, Change> changes = FeatureFlags.computeChanges(oldMap, newMap);
Expand All @@ -410,6 +414,8 @@ public void computeChanges_generic() {
assertEquals(Change.ENABLED, changes.get("e"));
assertEquals(Change.DISABLED, changes.get("f"));
assertEquals(Change.CHANGED, changes.get("h"));
assertFalse(changes.containsKey("i"));
assertEquals(Change.CHANGED, changes.get("j"));
}

private static <V> Set<V> setOf(V... values) {
Expand Down

0 comments on commit 51d47ad

Please sign in to comment.