Repository: incubator-brooklyn Updated Branches: refs/heads/master 3082169da -> 6aefffd59
Fix UpdatingMap for if suppressDuplicates=true - log.warn to say it should not be set. - reset config to suppressDuplicates=false Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/66d17a4f Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/66d17a4f Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/66d17a4f Branch: refs/heads/master Commit: 66d17a4f112b2e30948ba20ecf710a7213562692 Parents: 3b5b235 Author: Aled Sage <[email protected]> Authored: Sat Sep 19 15:52:21 2015 +0100 Committer: Aled Sage <[email protected]> Committed: Mon Sep 21 14:31:51 2015 +0100 ---------------------------------------------------------------------- .../brooklyn/enricher/stock/UpdatingMap.java | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/66d17a4f/core/src/main/java/org/apache/brooklyn/enricher/stock/UpdatingMap.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/enricher/stock/UpdatingMap.java b/core/src/main/java/org/apache/brooklyn/enricher/stock/UpdatingMap.java index b09b6d6..e4828cb 100644 --- a/core/src/main/java/org/apache/brooklyn/enricher/stock/UpdatingMap.java +++ b/core/src/main/java/org/apache/brooklyn/enricher/stock/UpdatingMap.java @@ -87,11 +87,30 @@ public class UpdatingMap<S,TKey,TVal> extends AbstractEnricher implements Sensor public UpdatingMap(Map<Object, Object> flags) { super(flags); + } + + @Override + public void init() { + super.init(); + // this always suppresses duplicates, but it updates the same map *in place* so the usual suppress duplicates logic should not be applied // TODO clean up so that we have synchronization guarantees and can inspect the item to see whether it has changed - suppressDuplicates = false; + if (Boolean.TRUE.equals(getConfig(SUPPRESS_DUPLICATES))) { + LOG.warn("suppress-duplicates must not be set on "+this+" because map is updated in-place; unsetting config; will always implicitly suppress duplicates"); + config().set(SUPPRESS_DUPLICATES, (Boolean)null); + } } - + + @Override + protected <T> void doReconfigureConfig(ConfigKey<T> key, T val) { + if (key.getName().equals(SUPPRESS_DUPLICATES.getName())) { + if (Boolean.TRUE.equals(val)) { + throw new UnsupportedOperationException("suppress-duplicates must not be set on "+this+" because map is updated in-place; will always implicitly suppress duplicates"); + } + } + super.doReconfigureConfig(key, val); + } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void setEntity(EntityLocal entity) {
