Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/213#discussion_r18506584
--- Diff:
core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java
---
@@ -131,9 +133,19 @@ protected void forceGc() {
return
Tasks.builder().name(name).dynamic(false).body(Callables.returning(null));
}
- protected static void assertTaskCountForEntity(Entity entity, int
expectedCount) {
- Collection<Task<?>> tasks =
BrooklynTaskTags.getTasksInEntityContext(((EntityInternal)entity).getManagementContext().getExecutionManager(),
entity);
- Assert.assertEquals(tasks.size(), expectedCount, "Tasks were
"+tasks);
+ protected void assertTaskCountForEntitySoon(final Entity entity, final
int expectedCount) {
+ // Dead task (and initialization task) should have been GC'd on
completion.
+ // However, the GC'ing happens in a listener, executed in a
different thread - the task.get()
+ // doesn't block for it. Therefore can't always guarantee it will
be GC'ed by now.
+ Repeater.create().backoff(Duration.millis(10), 2,
Duration.millis(500)).limitTimeTo(Duration.TEN_SECONDS).until(new
Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ forceGc();
--- End diff --
Do we really need to call `forceGc()`? If the comment `Dead task (and
initialization task) should have been GC'd on completion` is correct then
presumably not. But I'm guessing this method is now used in more places so the
comment is no longer applicable?
---
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.
---