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 17, 2018
1 parent 269d926 commit 636ff38
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 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 @@ -1697,5 +1697,16 @@ private IEnumerable<Plan<int>> GetPlans(Exception ex)
}

#endregion

[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 636ff38

Please sign in to comment.