mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Fix tools service crash + improve server edition naming (#506)
* Fix https://github.com/Microsoft/vscode-mssql/issues/986 and add better server edition naming - Fixed a number of issues related to the binding queue, specifically the fact that it didn't capture exceptions that occurred on the binding thread. This caused the thread to crash the service. - The root cause of the error was when you get a connection error during init of the SmoMetadataProvider which threw an exception. Because of this no Binder was created, and the code would null ref later during processing - Added logic to handle null ref issue and other related code - Added a unit test for the new error handling path, and supported still returning some value in this case - Separately, have a fix for an issue where the edition is shown as "SQL Azure" for all Azure connections. Fixing to be "Azure SQL DB" for this case and handle when the database reports as DW or Stretch instead. This maps better to users concept of what the edition should be and avoids returning what is an outdated term. * Messed up the test - fixing this by returning the expected return object
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.SmoMetadataProvider;
|
||||
@@ -133,6 +134,35 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
Assert.False(this.isCancelationRequested);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues a single task
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void QueueWithUnhandledExceptionTest()
|
||||
{
|
||||
InitializeTestSettings();
|
||||
ManualResetEvent mre = new ManualResetEvent(false);
|
||||
bool isExceptionHandled = false;
|
||||
object defaultReturnObject = new object();
|
||||
var queueItem = this.bindingQueue.QueueBindingOperation(
|
||||
key: "testkey",
|
||||
bindOperation: (context, CancellationToken) => throw new Exception("Unhandled!!"),
|
||||
timeoutOperation: TestTimeoutOperation,
|
||||
errorHandler: (exception) => {
|
||||
isExceptionHandled = true;
|
||||
mre.Set();
|
||||
return defaultReturnObject;
|
||||
});
|
||||
|
||||
mre.WaitOne(10000);
|
||||
|
||||
this.bindingQueue.StopQueueProcessor(15000);
|
||||
|
||||
Assert.True(isExceptionHandled);
|
||||
var result = queueItem.GetResultAsT<object>();
|
||||
Assert.Equal(defaultReturnObject, result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queue a 100 short tasks
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user