mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 01:25:37 -05:00
fix listener leaks (#17913)
* fix listener leaks * add null check * simplify * pr comments
This commit is contained in:
@@ -11,6 +11,7 @@ import { ConnectionProfile } from 'sql/platform/connection/common/connectionProf
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { IConnectionProfile, ProfileMatcher } from 'sql/platform/connection/common/interfaces';
|
||||
import { ICredentialsService } from 'sql/platform/credentials/common/credentialsService';
|
||||
import { isDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
|
||||
@@ -112,6 +113,9 @@ export class ConnectionStore {
|
||||
// Add the profile to the saved list, taking care to clear out the password field if necessary
|
||||
const savedProfile = forceWritePlaintextPassword ? profile : this.getProfileWithoutPassword(profile);
|
||||
const savedConnectionProfile = await this.saveProfileToConfig(savedProfile, matcher);
|
||||
if (isDisposable(savedProfile)) {
|
||||
savedProfile.dispose();
|
||||
}
|
||||
profile.groupId = savedConnectionProfile.groupId;
|
||||
profile.id = savedConnectionProfile.id;
|
||||
// Only save if we successfully added the profile
|
||||
@@ -177,9 +181,9 @@ export class ConnectionStore {
|
||||
|
||||
public getProfileWithoutPassword(conn: IConnectionProfile): ConnectionProfile {
|
||||
let savedConn = ConnectionProfile.fromIConnectionProfile(this.capabilitiesService, conn);
|
||||
savedConn = savedConn.withoutPassword();
|
||||
|
||||
return savedConn;
|
||||
let newSavedConn = savedConn.withoutPassword();
|
||||
savedConn.dispose();
|
||||
return newSavedConn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +229,9 @@ export class ConnectionStore {
|
||||
|
||||
list.unshift(savedProfile);
|
||||
|
||||
return list.filter(n => n !== undefined).map(c => c.toIConnectionProfile());
|
||||
const profiles = list.filter(n => n !== undefined).map(c => c.toIConnectionProfile());
|
||||
list.forEach(c => c.dispose());
|
||||
return profiles;
|
||||
}
|
||||
|
||||
private removeFromConnectionList(conn: IConnectionProfile, list: ConnectionProfile[]): IConnectionProfile[] {
|
||||
|
||||
Reference in New Issue
Block a user