This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
The following commit(s) were added to refs/heads/master by this push:
new c870570 fix bug where id cannot be set on an entity if it doesn't use
an interface
c870570 is described below
commit c870570b631556d4a7f4edcf4d61362c5490a6ea
Author: Alex Heneveld <[email protected]>
AuthorDate: Tue Apr 13 11:21:31 2021 +0100
fix bug where id cannot be set on an entity if it doesn't use an interface
---
.../brooklyn/spi/creation/BrooklynComponentTemplateResolver.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git
a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
index 97992f7..db54ba5 100644
---
a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
+++
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
@@ -464,6 +464,11 @@ public class BrooklynComponentTemplateResolver {
for (Class<?> iface : spec.getAdditionalInterfaces()) {
allKeys.addAll(FlagUtils.findAllFlagsAndConfigKeys(null, iface,
bagFlags));
}
+ if (!allKeys.isEmpty() && allKeys.stream().filter(k ->
"id".equals(k.getFlagName())).findAny().isPresent()) {
+ // remove the 'id' flag, e.g. if a spec class is not an interface
and picks up AbstractBrooklynObject.id
+ // because the 'id' flag should have been treated specially (this
logic could go elsewhere, but this seems as good a place as any)
+ allKeys = MutableList.copyOf( allKeys.stream().filter(k ->
!"id".equals(k.getFlagName())).iterator() );
+ }
return allKeys;
}