Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/287#discussion_r73672524
--- Diff:
core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java ---
@@ -1698,6 +1698,7 @@ public void add(Policy policy) {
CatalogUtils.setCatalogItemIdOnAddition(AbstractEntity.this,
policy);
policiesInternal.add((AbstractPolicy)policy);
((AbstractPolicy)policy).setEntity(AbstractEntity.this);
+ ConfigConstraints.assertValid(policy);
--- End diff --
Seems strange to add + activate the policy, and only then assert that it is
valid. But I guess it might not be fully initialised before `setEntity` is
called, for us to validate it?
Hopefully the policy was instantiated using the normal mechanism (so went
through `InternalPolicyFactory.createPolicy`, which will have called
`assertValid`.
Are there situations where this code catches something we were previously
missing? If so, should we write a **test** for it?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---