addressed code review comments on making ConfigBag thread safe
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/4cffb0ac Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/4cffb0ac Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/4cffb0ac Branch: refs/heads/master Commit: 4cffb0acde90713bfad090524cbd71b32a32cd68 Parents: 5e34f95 Author: Alex Heneveld <[email protected]> Authored: Sun Apr 12 20:11:03 2015 -0500 Committer: Alex Heneveld <[email protected]> Committed: Sun Apr 12 20:11:03 2015 -0500 ---------------------------------------------------------------------- core/src/main/java/brooklyn/util/config/ConfigBag.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cffb0ac/core/src/main/java/brooklyn/util/config/ConfigBag.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/util/config/ConfigBag.java b/core/src/main/java/brooklyn/util/config/ConfigBag.java index 220ec52..606e2fc 100644 --- a/core/src/main/java/brooklyn/util/config/ConfigBag.java +++ b/core/src/main/java/brooklyn/util/config/ConfigBag.java @@ -49,7 +49,8 @@ import com.google.common.collect.Sets; * although in some cases (such as setting fields from flags, or copying a map) * it may be necessary to mark things as used, or put, when only a string key is available. * <p> - * This bag is order-preserving and thread-safe except where otherwise indicated. + * This bag is order-preserving and thread-safe except where otherwise indicated, + * currently by synching on this instance (but that behaviour may change). * <p> * @author alex */ @@ -104,14 +105,15 @@ public class ConfigBag { */ @Beta public static ConfigBag newInstanceExtending(final ConfigBag parentBag) { - return new ConfigBagExtendingParent(parentBag).copy(parentBag); + return new ConfigBagExtendingParent(parentBag); } /** @see #newInstanceExtending(ConfigBag) */ - public static class ConfigBagExtendingParent extends ConfigBag { + private static class ConfigBagExtendingParent extends ConfigBag { ConfigBag parentBag; private ConfigBagExtendingParent(ConfigBag parentBag) { this.parentBag = parentBag; + copy(parentBag); } @Override public void markUsed(String key) {
