Skip to content

Commit

Permalink
Fix last ReSharper warning
Browse files Browse the repository at this point in the history
Protect against possible null from base class
  • Loading branch information
Thibaud DESODT committed Oct 23, 2017
1 parent c10e625 commit 1b4abc4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Serilog/Context/LogContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,8 @@ public DisposableObjectHandle(object o) : base(o)

public override object InitializeLifetimeService()
{
var lease = (ILease)base.InitializeLifetimeService();
// ReSharper disable once PossibleNullReferenceException
// not 100% sure this will never occur ...
lease.Register(LifeTimeSponsor);
var lease = base.InitializeLifetimeService() as ILease;
lease?.Register(LifeTimeSponsor);
return lease;
}

Expand Down

0 comments on commit 1b4abc4

Please sign in to comment.