GitHub user aledsage opened a pull request:

    https://github.com/apache/brooklyn-server/pull/883

    Deprecates use of Task in ConfigKey

    Also avoid `StackOverflowError` in `ExecutionContext.getImmediately(task)`
    When a non-`BasicTask` is passed in.
    
    ---
    The motivation for deprecating setting a `ConfigKey` as a `Task` is that we 
really shouldn't be doing it! It can get very messed up if one tries to 
`getImmediately` or get non-blocking (e.g. by a `Transformer` that is trying to 
evaluate its result when triggered). That can leave the task in a cancelled 
state, so all subsequent calls to `task.get()` (i.e. all calls to 
`config().get(mykey)`) will fail!
    
    Instead, we should be using `TaskFactory` (which is how the DSL evaluation 
works).
    
    It's good to deprecate this before a major release of 1.0.0.
    
    It would be good to add an overloaded method for setting config to 
`set(ConfigKey<T>, TaskFactory<T>)` so that such usage doesn't involve ugly 
casting to work around the strongly typed generics. We can do that as a stage 
two, separate from this PR.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aledsage/brooklyn-server 
deprecate-configkey-tasks

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/883.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #883
    
----
commit 2e4fc3e205df4f9da01751fc2aba4ea004ef96bf
Author: Aled Sage <[email protected]>
Date:   2017-11-07T16:51:54Z

    Deprecates use of Task in ConfigKey
    
    Also avoid StackOverflowError in ExecutionContext.getImmediately(task)
    When a non-BasicTask is passed in.

----


---

Reply via email to