Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/101#discussion_r15671427
  
    --- Diff: core/src/main/java/brooklyn/entity/basic/AbstractEntity.java ---
    @@ -1135,11 +1143,49 @@ public boolean removeAllPolicies() {
     
         @Override
         public void addEnricher(Enricher enricher) {
    +        List<Enricher> old = MutableList.<Enricher>copyOf(enrichers);
    +        
             enrichers.add((AbstractEnricher) enricher);
             ((AbstractEnricher)enricher).setEntity(this);
             
             
getManagementSupport().getEntityChangeListener().onEnricherAdded(enricher);
             // TODO Could add equivalent of AbstractEntity.POLICY_ADDED for 
enrichers; no use-case for that yet
    +        
    +        if (hasApparentlyEqualsAndWarn(old, enricher)) 
removeEnricher(enricher);
    +    }
    +    
    +    private <T> boolean hasApparentlyEqualsAndWarn(Collection<? extends T> 
items, T newItem) {
    +        T oldItem = findApparentlyEquals(items, newItem);
    +        if (oldItem!=null) {
    +            LOG.warn("Adding to "+this+", "+newItem+" appears identical to 
existing "+oldItem+"; will remove after adding");
    --- End diff --
    
    I'd also say in the message about the need for the user to fix it - that 
this behaviour cannot be relied upon in the next or future releases.


---
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.
---

Reply via email to