Skip to content

Commit

Permalink
new standin for IChainExecutionLog to avoid memory leaks. Closes GH-926
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Sep 1, 2015
1 parent eab9c53 commit 67875f7
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
57 changes: 57 additions & 0 deletions src/FubuMVC.Core/Diagnostics/Instrumentation/IChainExecutionLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,61 @@ public interface IChainExecutionLog
Guid Id { get; }
BehaviorChain RootChain { get; set; }
}


public class NulloChainExecutionLog : IChainExecutionLog
{
public void StartSubject(ISubject subject)
{
// nothing
}

public void FinishSubject()
{
// nothing
}

public void LogException(Exception ex)
{
// nothing
}

public void Log(object log)
{
// nothing
}

public void Trace(string description, Action action)
{
// nothing
action();
}

public void RecordHeaders(IDictionary<string, object> env)
{
// nothing
}

public void RecordBody(IDictionary<string, object> env)
{
// nothing
}

public void RecordHeaders(Envelope envelope)
{
// nothing
}

public void RecordBody(Envelope envelope)
{
// nothing
}

public Guid Id
{
get { return Guid.Empty; }
}

public BehaviorChain RootChain { get; set; }
}
}
4 changes: 3 additions & 1 deletion src/FubuMVC.Core/Http/HttpStandinServiceRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public HttpStandInServiceRegistry()
For<RouteData>().Use(new RouteData());
For<IDictionary<string, object>>().Use(new Dictionary<string, object>());

For<IChainExecutionLog>().Use<ChainExecutionLog>();
// This is important, really needs to be the nullo to avoid
// hanging on to things we shouldn't
For<IChainExecutionLog>().Use<NulloChainExecutionLog>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public void verbose_registrations()
c.ShouldHaveRegistration<ILogListener, ChainExecutionListener>();

c.DefaultRegistrationIs<IPartialFactory, DiagnosticPartialFactory>();

c.DefaultRegistrationIs<IChainExecutionLog, NulloChainExecutionLog>();
});
}

Expand All @@ -112,6 +114,8 @@ public void production_registration()

c.DefaultRegistrationIs<IPartialFactory, PartialFactory>();

c.DefaultRegistrationIs<IChainExecutionLog, NulloChainExecutionLog>();

});
}

Expand All @@ -129,6 +133,8 @@ public void trace_level_is_none_registration()
c.ShouldNotHaveRegistration<ILogListener, ChainExecutionListener>();

c.DefaultRegistrationIs<IPartialFactory, PartialFactory>();

c.DefaultRegistrationIs<IChainExecutionLog, NulloChainExecutionLog>();
});
}
}
Expand Down

0 comments on commit 67875f7

Please sign in to comment.