Github user Graeme-Miller commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/342#discussion_r80075903
--- Diff:
core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalUsageManager.java
---
@@ -173,20 +180,23 @@
public LocalUsageManager(LocalManagementContext managementContext) {
this.managementContext = checkNotNull(managementContext,
"managementContext");
- // TODO Once
org.apache.brooklyn.core.management.internal.UsageManager.UsageListener is
deleted, restore this
- // to normal generics!
+ // Although changing listeners to Collection<UsageListener> is
valid at compile time
+ // the collection will contain any objects that could not be
coerced by the function
+ // declared above. Generally this means any string declared in
brooklyn.properties
+ // that is not a UsageListener.
Collection<?> listeners =
managementContext.getBrooklynProperties().getConfig(UsageManager.USAGE_LISTENERS);
if (listeners != null) {
- for (Object listener : listeners) {
- if (listener instanceof ManagementContextInjectable) {
-
((ManagementContextInjectable)listener).setManagementContext(managementContext);
- }
- if (listener instanceof UsageListener) {
- addUsageListener((UsageListener)listener);
- } else if (listener == null) {
- throw new NullPointerException("null listener in
config "+UsageManager.USAGE_LISTENERS);
+ for (Object obj : listeners) {
+ if (obj == null) {
+ throw new NullPointerException("null listener in
config " + UsageManager.USAGE_LISTENERS);
+ } else if (!(obj instanceof UsageListener)) {
+ throw new ClassCastException("Configured object is not
a UsageListener. This probably means coercion failed: " + obj);
} else {
--- End diff --
doesn't really need to be an else anymore
---
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.
---