From 188ccf849d2d937f3b37d2550a0569ed83bc677f Mon Sep 17 00:00:00 2001 From: Karl Burtram Date: Thu, 2 May 2019 16:04:03 -0700 Subject: [PATCH] Fix nullref exception in connection profile (#5330) * Fix nullref exception in connection profile * Fix condition --- .../platform/connection/common/connectionProfile.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sql/platform/connection/common/connectionProfile.ts b/src/sql/platform/connection/common/connectionProfile.ts index 75e97378bb..252c8a812d 100644 --- a/src/sql/platform/connection/common/connectionProfile.ts +++ b/src/sql/platform/connection/common/connectionProfile.ts @@ -58,14 +58,19 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa public matches(other: interfaces.IConnectionProfile): boolean { return other && this.providerName === other.providerName - && equalsIgnoreCase(this.serverName, other.serverName) - && equalsIgnoreCase(this.databaseName, other.databaseName) - && equalsIgnoreCase(this.userName, other.userName) - && equalsIgnoreCase(this.options['databaseDisplayName'], other.options['databaseDisplayName']) + && this.nullCheckEqualsIgnoreCase(this.serverName, other.serverName) + && this.nullCheckEqualsIgnoreCase(this.databaseName, other.databaseName) + && this.nullCheckEqualsIgnoreCase(this.userName, other.userName) + && this.nullCheckEqualsIgnoreCase(this.options['databaseDisplayName'], other.options['databaseDisplayName']) && this.authenticationType === other.authenticationType && this.groupId === other.groupId; } + private nullCheckEqualsIgnoreCase(a: string, b: string) { + let bothNull: boolean = !a && !b; + return bothNull ? bothNull : equalsIgnoreCase(a, b); + } + public generateNewId() { this._id = generateUuid(); }