Avoid crash with Kayak when drain is null #77

Merged
merged 2 commits into from Mar 26, 2012

Projects

None yet

3 participants

@mcunha
Contributor
mcunha commented Mar 21, 2012

Default stack of:
builder
.RescheduleCallbacks()
.RunNancy();

Will crash with NullReferenceException due to drain being null. Adapter should check before invoking.

@loudej
Contributor
loudej commented Mar 26, 2012

Great, thanks for the fix!

@loudej loudej merged commit 2c44575 into owin:master Mar 26, 2012
@jrsconfitto

Maybe i'm missing something, but i pulled down this package last night, and this doesn't compile in Visual Studio for me.

Is this the uglier way to write that?

if (!flush(() => 
    {
        if (drained != null) 
        {
            theScheduler.Post(drained);
        }
    })) 
{
    if (drained != null) {
        drained.Invoke();
    }
}
@mcunha
Contributor
mcunha commented Apr 24, 2012

That's correct. Or the shorter version below should work too:

if (!flush(() => { if (drained != null) theScheduler.Post(drained); }))
  if (drained != null) drained.Invoke();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment