Modified collection exception in GetUserFromNickName

Bug #1254113 reported by Michael Holland
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
IRC.NET
Fix Committed
Undecided
Unassigned

Bug Description

Call stack points at call to "SingleOrDefault" in the method "GetUserFromNickName(string nickName, bool isOnline, out bool creatdNew)"

specific line is as follows:
var user = this.users.SingleOrDefault(u => u.NickName == nickname);

Perhaps the call to "lock (((ICollection)this.userReadonly).SyncRoot)" should be called before the above line instead of after as the above linq does an enumeration.

Error Message:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at IrcDotNet.IrcClient.GetUserFromNickName(String nickName, Boolean isOnline, Boolean& createdNew)
at IrcDotNet.IrcClient.GetMessageTarget(String targetName)
at IrcDotNet.IrcClient.ProcessMessageNoticeb__d(String n)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at IrcDotNet.IrcClient.ProcessMessageNotice(IrcMessage message)
at IrcDotNet.IrcClient.ReadMessage(IrcMessage message, String line)

Revision history for this message
Alexander Regueiro (alexreg) wrote :
Changed in ircdotnet:
status: New → Confirmed
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.