You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2016/11/10 13:59:59 UTC

[GitHub] brooklyn-server pull request #385: Don't allow multiple context entities in ...

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

    https://github.com/apache/brooklyn-server/pull/385#discussion_r87398136
  
    --- Diff: core/src/main/java/org/apache/brooklyn/util/core/task/BasicExecutionContext.java ---
    @@ -203,11 +211,46 @@ public Void apply(Task<?> it) {
                 throw new IllegalArgumentException("Unhandled task type: task="+task+"; type="+(task!=null ? task.getClass() : "null"));
             }
         }
    -    
    +
         private void registerPerThreadExecutionContext() { perThreadExecutionContext.set(this); }
     
         private void clearPerThreadExecutionContext() { perThreadExecutionContext.remove(); }
     
    +    private void checkUserSuppliedContext(Object task, Collection<Object> taskTags) {
    +        Entity taskContext = BrooklynTaskTags.getWrappedEntityOfType(taskTags, BrooklynTaskTags.CONTEXT_ENTITY);
    +        Entity defaultContext = BrooklynTaskTags.getWrappedEntityOfType(tags, BrooklynTaskTags.CONTEXT_ENTITY);
    +        if (taskContext != null) {
    +            if (log.isWarnEnabled()) {
    +                String msg = "Deprecated since 0.10.0. Task " + task + " is submitted for execution but has context " +
    +                        "entity (" + taskContext + ") tag set by the caller. ";
    +                if (taskContext != defaultContext) {
    +                    msg += "The context entity of the execution context (" + this + ") the task is submitted on is " +
    +                            defaultContext + " which is different. This will cause any of them to be used at random at " +
    +                            "runtime. ";
    +                    if (task instanceof BasicTask) {
    +                        msg += "Fixing the context entity to the latter. ";
    +                    }
    +                }
    +                msg += "Setting the context entity by the caller is not allowed. See the documentation on " +
    +                        "BrooklynTaskTags.tagForContextEntity(Entity) method for more details. Future Apache Brooklyn " +
    +                        "releases will throw an exception instead of logging a warning.";
    +
    +                /**
    +                 * @deprecated since 0.10.0
    +                 */
    +                // Should we rate limit?
    +                log.warn(msg);
    --- End diff --
    
    Let's monitor (including grep'ing the output logs from the mvn build), and rate limit if we're seeing this a lot.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---