Close connection explicitly on rename (#2129)

This commit is contained in:
Cheena Malhotra
2023-07-06 22:19:17 -07:00
committed by GitHub
parent 226b30ffbd
commit 03a99e48dc

View File

@@ -74,6 +74,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
throw new Exception(SR.ObjectNotRenamable(objectUrn));
}
}
// If connection is not instantiated in the using statement, it can be leaked here, therefore close explicitly.
if(serverConnection.SqlConnectionObject.State == System.Data.ConnectionState.Open)
{
serverConnection.SqlConnectionObject.Close();
}
return Task.CompletedTask;
}