[
https://issues.apache.org/jira/browse/BROOKLYN-278?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15298152#comment-15298152
]
ASF GitHub Bot commented on BROOKLYN-278:
-----------------------------------------
Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/154#discussion_r64388088
--- Diff:
core/src/main/java/org/apache/brooklyn/enricher/stock/Propagator.java ---
@@ -113,33 +136,15 @@ public void setEntity(EntityLocal entity) {
return true;
}
};
- } else if (sensorMappingSet) {
- if (propagatingAll) {
- throw new IllegalStateException("Propagator enricher
"+this+" must not have 'sensorMapping' set at same time as either
'propagatingAll' or 'propagatingAllBut'");
- }
- this.sensorMapping = ImmutableMap.copyOf(sensorMappingTemp);
+ } else if (sensorMapping.size() > 0) {
+ this.sensorMapping = ImmutableMap.copyOf(sensorMapping);
this.sensorFilter = Predicates.alwaysTrue();
} else {
- this.sensorMapping = ImmutableMap.<Sensor<?>, Sensor<?>>of();
- if (!propagatingAll) {
- // default if nothing specified is to do all but the ones
not usually propagated
- propagatingAll = true;
- // user specified nothing, so *set* the all_but to the
default set
- // if desired, we could allow this to be dynamically
reconfigurable, remove this field and always look up;
- // slight performance hit (always looking up), and might
need to recompute subscriptions, so not supported currently
- // TODO this default is @Beta behaviour! -- maybe better
to throw?
- propagatingAllBut = SENSORS_NOT_USUALLY_PROPAGATED;
- } else {
- propagatingAllBut = getConfig(PROPAGATING_ALL_BUT);
- }
+ assert propagatingAll;
--- End diff --
Could this not use org.apache.brooklyn.test.Asserts or
com.google.common.base.Preconditions and add a message?
> default Propagator enricher can cause infinite subscription event loop
> ----------------------------------------------------------------------
>
> Key: BROOKLYN-278
> URL: https://issues.apache.org/jira/browse/BROOKLYN-278
> Project: Brooklyn
> Issue Type: Bug
> Affects Versions: 0.9.0
> Reporter: Aled Sage
>
> The default {{Propagator}} can cause an infinite loop: it subscribes to all
> sensor events from that entity, and republishes them!
> For example, the blueprint below demonstrates this:
> {noformat}
> location: localhost
> services:
> - type: org.apache.brooklyn.entity.stock.BasicApplication
> brooklyn.enrichers:
> - type: org.apache.brooklyn.enricher.stock.Propagator
> {noformat}
> This shows repeated log messages like:
> {noformat}
> 2016-05-23 14:09:09,069 DEBUG o.a.b.c.entity.AbstractEntity
> [brooklyn-execmanager-B5OU5RXp-6]: Emitting sensor notification
> entity.location.added value LocalhostMachineProvisioningLocation{id=U27ANQ3v,
> name=localhost} on BasicApplicationImpl{id=C8KeD18W}
> {noformat}
> I'd expect such missing propagator config to cause it to fail. Or if it was
> misconfigured to cause an infinite loop, then that would also cause a failure.
> For example, the blueprint below also produces an infinite loop and should be
> forbidden:
> {noformat}
> location: localhost
> services:
> - type: org.apache.brooklyn.entity.stock.BasicApplication
> id: app
> brooklyn.enrichers:
> - type: org.apache.brooklyn.enricher.stock.Propagator
> brooklyn.config:
> producer: $brooklyn:entity("app")
> propagatingAll: true
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)