Skip to content

Commit

Permalink
4.x: Fix ActivePlan crashing with self-joins
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd committed May 26, 2018
1 parent 34f7bb1 commit c0f3d2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Rx.NET/Source/src/System.Reactive/Joins/ActivePlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ internal abstract class ActivePlan

protected void AddJoinObserver(IJoinObserver joinObserver)
{
joinObservers.Add(joinObserver, joinObserver);
if (!joinObservers.ContainsKey(joinObserver))
{
joinObservers.Add(joinObserver, joinObserver);
}
}

protected void Dequeue()
Expand Down Expand Up @@ -1432,4 +1435,4 @@ internal override void Match()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,15 @@ private IEnumerable<Plan<int>> GetPlans(Exception ex)
yield break;
}

[Fact]
public void SameSource()
{
var source = Observable.Range(1, 5);

var list = Observable.When(source.And(source).Then((a, b) => a + b))
.ToList().First();

Assert.Equal(new List<int>() { 2, 4, 6, 8, 10 }, list);
}
}
}

0 comments on commit c0f3d2f

Please sign in to comment.