Skip to content

Commit

Permalink
fix:fix config recreate NPE.
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyeBeFreeman committed Nov 8, 2024
1 parent bc53f1c commit 45cf955
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,6 @@ public void addConfigFile(RemoteConfigFileRepo remoteConfigFileRepo) {
}
}

public void removeConfigFile(RemoteConfigFileRepo remoteConfigFileRepo) {
ConfigFileMetadata configFileMetadata = remoteConfigFileRepo.getConfigFileMetadata();
long version = remoteConfigFileRepo.getConfigFileVersion();
LOGGER.info("[Config] remove long polling config file. file = {}, version = {}", configFileMetadata, version);
configFilePool.remove(configFileMetadata);
//长轮询起始的配置文件版本号应该以第一次同步拉取为准
notifiedVersion.remove(configFileMetadata);
}

private void startLongPollingTask() {
if (!started.compareAndSet(false, true)) {
return;
Expand Down Expand Up @@ -157,7 +148,7 @@ private void doLongPolling() {
changedConfigFile.getFileGroup(),
changedConfigFile.getFileName());
long newNotifiedVersion = changedConfigFile.getVersion();
long oldNotifiedVersion = notifiedVersion.get(metadata);
long oldNotifiedVersion = notifiedVersion.getOrDefault(metadata, -1L);

long maxVersion = newNotifiedVersion;
if (connector.isNotifiedVersionIncreaseStrictly()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,6 @@ public ConfigKVFile getConfigKVFile(ConfigFileMetadata configFileMetadata, Confi
return configFile;
}

public ConfigKVFile removeConfigKVFile(ConfigFileMetadata configFileMetadata) {
ConfigKVFile configFile = null;
synchronized (this) {
configFile = configPropertiesFileCache.get(configFileMetadata);
if (configFile != null) {
configFile = configPropertiesFileCache.remove(configFileMetadata);
}
}
return configFile;
}

public ConfigFileResponse createConfigFile(CreateConfigFileRequest request) {
com.tencent.polaris.api.plugin.configuration.ConfigFile configFile =
new com.tencent.polaris.api.plugin.configuration.ConfigFile(request.getNamespace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.tencent.polaris.client.api.SDKContext;
import com.tencent.polaris.client.util.NamedThreadFactory;
import com.tencent.polaris.configuration.api.core.ConfigFileMetadata;
import com.tencent.polaris.configuration.api.core.ConfigKVFile;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -193,8 +192,6 @@ protected void doPull() {
//删除配置文件
if (remoteConfigFile.get() != null) {
remoteConfigFile.set(null);
ConfigKVFile configKVFile = configFileManager.removeConfigKVFile(configFileMetadata);
pullService.removeConfigFile(this);
//删除配置文件也需要触发通知
fireChangeEvent(null);
}
Expand Down

0 comments on commit 45cf955

Please sign in to comment.