Clone
bouvrie <bouvrie@example.com>
committed
on 31 Mar 17
* Fix attempt for bug in buildserver.
Should fix the following exception occurring on teamcity:
Expected: No Exception to be thrown
But … Show more
* Fix attempt for bug in buildserver.

Should fix the following exception occurring on teamcity:

 Expected: No Exception to be thrown

 But was:  <System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

  at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)

  at System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator.MoveNext()

  at Core.Common.TestUtil.FileDisposeHelper.Create()

  at Core.Common.TestUtil.FileDisposeHelper..ctor(IEnumerable`1 filePaths)

  at Core.Common.TestUtil.Test.FileDisposeHelperTest.<>c__DisplayClass5_0.<Constructor_InvalidPath_DoesNotThrowException>b__0()

  at NUnit.Framework.Constraints.ThrowsConstraint.VoidInvocationDescriptor.Invoke()

  at NUnit.Framework.Constraints.ThrowsConstraint.ExceptionInterceptor.Intercept(Object invocation)>

at Core.Common.TestUtil.Test.FileDisposeHelperTest.Constructor_InvalidPath_DoesNotThrowException()

Analysis:

The dictionary is not changed while it is being enumerated. The relevant code is called from within the constructor, so there cannot be another thread attempting to do work on that FileDisposeHelper instance as no reference to that instance has been produced yet. The 'foreach' inside the constructor of FileDisposeHelper over all filepaths will enumerate that particular collection and add member to the dictionary before the Create method is called. From this analysis, I dare to conclude that it is impossible that there are any changes to the dictionary from within the Create method when it is called from the constructor of FileDisposeHelper.

However, failing tests on the buildserver with stacktrace prove otherwise. This at least ought to solve the problem, but it's likely treating symptoms than the actual root cause of the problem.

Related to Issue [WTI-1229]

git-svn-id: https://repos.deltares.nl/repos/WettelijkToetsInstrumentarium/trunk@9057 5a3db67b-de53-47b5-99c8-a1c30a6650e2

Former-commit-id: 9115d5114f3133b79811fb9f0ec1b417431be9f2

Former-commit-id: 1a64da7f60a42c228acb0a0c6776169a436d7185 Show less

1691 + 77 more