Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ Apollo Java 2.2.0
------------------
[refactor(apollo-client): Optimize the exception message when failing to retrieve configuration information.](https://github.com/apolloconfig/apollo-java/pull/22)
[Add JUnit5 extension support for apollo mock server.](https://github.com/apolloconfig/apollo-java/pull/25)
[Support concurrent loading of Config for different namespaces.](https://github.com/apolloconfig/apollo-java/pull/31)
------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo-java/milestone/2?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public class DefaultConfigManager implements ConfigManager {
private ConfigFactoryManager m_factoryManager;

private Map<String, Config> m_configs = Maps.newConcurrentMap();
private Map<String, Object> m_configLocks = Maps.newConcurrentMap();
private Map<String, ConfigFile> m_configFiles = Maps.newConcurrentMap();
private Map<String, Object> m_configFileLocks = Maps.newConcurrentMap();

public DefaultConfigManager() {
m_factoryManager = ApolloInjector.getInstance(ConfigFactoryManager.class);
Expand All @@ -44,7 +46,8 @@ public Config getConfig(String namespace) {
Config config = m_configs.get(namespace);

if (config == null) {
synchronized (this) {
Object lock = m_configLocks.computeIfAbsent(namespace, key -> new Object());
synchronized (lock) {
config = m_configs.get(namespace);

if (config == null) {
Expand All @@ -65,7 +68,8 @@ public ConfigFile getConfigFile(String namespace, ConfigFileFormat configFileFor
ConfigFile configFile = m_configFiles.get(namespaceFileName);

if (configFile == null) {
synchronized (this) {
Object lock = m_configFileLocks.computeIfAbsent(namespaceFileName, key -> new Object());
synchronized (lock) {
configFile = m_configFiles.get(namespaceFileName);

if (configFile == null) {
Expand Down