DefaultCloseStrategy appears to never close closables even if all of them are closable.

Topics: Actions & Coroutines, Bugs
Oct 13, 2011 at 9:41 PM
Edited Oct 13, 2011 at 9:42 PM

DefaultCloseStrategy takes a parameter (closeConductedItemsWhenConductorCannotClose) which indicates whether it should pass the accumulated list of confirmed closables to the callback or an empty list.

It appears, however, that when this value is true, regardless if whether all closables can in fact close, an empty list is passed to the callback. Is this by design? It would seem that, by the name of the parameter, we should receive the list of all the closables if they all can close.

Oct 14, 2011 at 1:15 AM

Hmm. Sounds like a bug. I'm not sure how that happened. I'll need to investigate further to see what is going on. I'll create a ticket to remind me. Thanks.

Oct 14, 2011 at 3:10 PM

Looking at the code, I don't see how that could happen. Can you create a simple solution that demonstrates the issue and attach it to the ticket? Thanks.

Oct 19, 2011 at 2:10 AM

Ok, I now see my confusion. The variable name indicates to me that the ICloseStrategy performs the close, but in fact, it delegates that responsibility back to the callback passed to Evaluate.

Oct 19, 2011 at 2:36 AM

Now I have a related question, however. In Conductor<T>.Collection.OneActive.CanClose, the callback logic checks to see if the conductor can not close and if there are any closables. If this condition is true, then it attempts to close the closables. However, I'm not sure how this condition can arise, given that true is passed for canClose on the first call, true is passed for all items not implementing IGuardClose, and if an item implements IGuardClose it is added to closables only if its CanClose returns true. It seems that if closables.Any() is true, then canClose will also be true, and the code in the callback passed to the ICloseStrategy won't run. Am I missing something here?