Skip to content

Commit

Permalink
Fixed a bug in MessageRetryTracker.cs causing it to always return false
Browse files Browse the repository at this point in the history
  • Loading branch information
mouk authored and phatboyg committed Apr 4, 2011
1 parent 40422a8 commit 2d8a4de
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/MassTransit.Tests/MassTransit.Tests.csproj
Expand Up @@ -131,6 +131,7 @@
<Compile Include="Load\Sagas\FirstSaga.cs" />
<Compile Include="MessageContext_Specs.cs" />
<Compile Include="MessageInterceptor_Specs.cs" />
<Compile Include="MessageRetryTracker_Specs.cs" />
<Compile Include="Performance\EndpointLoadTest.cs" />
<Compile Include="Performance\LoadedRequest.cs" />
<Compile Include="Performance\LoadedResponse.cs" />
Expand Down
29 changes: 29 additions & 0 deletions src/MassTransit.Tests/MessageRetryTracker_Specs.cs
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MassTransit.Transports;
using NUnit.Framework;

namespace MassTransit.Tests
{
[TestFixture]
public class MessageRetryTracker_Specs
{
[Test]
public void IsLimitExceeded_return_false_untill_specified_limit_reached()
{
const int retryLimit = 5;

var tracker = new MessageRetryTracker(retryLimit);
const string id = "qelofjsw";

for (int i = 0; i < retryLimit; i++)
{
Assert.IsFalse(tracker.IsRetryLimitExceeded(id));
tracker.IncrementRetryCount(id);
}
Assert.IsTrue(tracker.IsRetryLimitExceeded(id));
}
}
}
2 changes: 1 addition & 1 deletion src/MassTransit/Transports/MessageRetryTracker.cs
Expand Up @@ -29,7 +29,7 @@ public MessageRetryTracker(int retryLimit)
public bool IsRetryLimitExceeded(string id)
{
int retryCount = 0;
if (_messages.ReadLock(x => x.TryGetValue(id, out retryCount)))
if (!_messages.ReadLock(x => x.TryGetValue(id, out retryCount)))
return false;

return retryCount >= _retryLimit;
Expand Down

0 comments on commit 2d8a4de

Please sign in to comment.