diff options
author | Matt Ward <ward.matt@gmail.com> | 2015-03-05 16:45:14 +0300 |
---|---|---|
committer | Matt Ward <ward.matt@gmail.com> | 2015-03-05 16:45:46 +0300 |
commit | 58dcff4877f18fadddcc99c7a1ea8713ea34e82c (patch) | |
tree | e112338c6b0577586d9813a19b5431e75c28b075 /main/src/addins/MonoDevelop.PackageManagement | |
parent | e504fb0f62b5e214ecc58bca0e2b45d5daacbb69 (diff) |
[NuGet] Prevent TaskCanceledException when check for updates cancelled
The NuGet addin was accessing the Task's Result when the task was
cancelled causing the TaskCanceledException to be thrown.
Diffstat (limited to 'main/src/addins/MonoDevelop.PackageManagement')
2 files changed, 22 insertions, 1 deletions
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs index 9a94d4ec7e..2da38bedfe 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs @@ -562,6 +562,25 @@ namespace MonoDevelop.PackageManagement.Tests Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
}
+
+ [Test]
+ public void CheckForUpdates_TaskCancelled_TaskResultIsNotReferenced ()
+ {
+ CreateUpdatedPackagesInSolution ();
+ taskFactory.RunTasksSynchronously = false;
+ FakePackageManagementProject project = AddProjectToSolution ();
+ project.AddPackageReference ("MyPackage", "1.0");
+ updatedPackagesInSolution.CheckForUpdates ();
+
+ var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
+ task.IsCancelled = true;
+ task.ExecuteTaskButNotContinueWith ();
+ task.Result = null;
+
+ Assert.DoesNotThrow (() => {
+ task.ExecuteContinueWith ();
+ });
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs index 22e040ba5b..0a01ea6163 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs @@ -112,8 +112,10 @@ namespace MonoDevelop.PackageManagement } else {
LoggingService.LogInternalError ("Check for updates task error.", task.Exception);
}
- } else if (task.IsCancelled || !IsCurrentTask (task.Result)) {
+ } else if (task.IsCancelled) {
// Ignore.
+ return;
+ } else if (!IsCurrentTask (task.Result)) {
task.Result.Dispose ();
return;
} else {
|