-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add multiple appId,pull other appId config into config. #70
base: main
Are you sure you want to change the base?
add multiple appId,pull other appId config into config. #70
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
WalkthroughThe recent updates to the Apollo Client introduce an Changes
Sequence DiagramsConfiguration Retrieval FlowsequenceDiagram
participant Client as Client
participant ConfigService as ConfigService
participant ConfigManager as ConfigManager
participant ConfigRepository as ConfigRepository
Client->>ConfigService: getConfig(appId, namespace)
ConfigService->>ConfigManager: getConfig(appId, namespace)
ConfigManager->>ConfigRepository: fetchConfig(appId, namespace)
ConfigRepository-->>ConfigManager: return Config
ConfigManager-->>ConfigService: return Config
ConfigService-->>Client: return Config
Configuration Change Notification FlowsequenceDiagram
participant ConfigRepository as ConfigRepository
participant RemoteConfigLongPollService as RemoteConfigLongPollService
participant Client as Client
ConfigRepository->>RemoteConfigLongPollService: submit(appId, namespace)
RemoteConfigLongPollService->>Client: notify(appId, namespace, changes)
Client-->>ConfigRepository: onRepositoryChange(appId, namespace, newProperties)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (4)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (1)
82-83
: UpdategetConfigFile
method calls to includeappId
parameter.The following instances of
getConfigFile
calls are still using the old signature and need to be updated to include theappId
parameter:
ApolloClientConfigurationFactory.java
- Line: 12
ConfigServiceTest.java
- Line: 4
DefaultConfigManagerTest.java
- Line: 12
- Line: 18
- Line: 24
Please update these method calls to match the new signature.
Analysis chain
Verify the function usage for the updated signature.
The
getConfigFile
method now includesappId
as a parameter. Ensure all calls to this method are updated accordingly.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `getConfigFile` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type java -A 5 $'getConfigFile'Length of output: 20390
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (2)
106-110
: Issue Found: UpdatesetConfig
Method to IncludeappId
ParameterThe
setConfig
method inConfigService.java
does not include the newappId
parameter as suggested in the review comment. Please update the method to include theappId
parameter.
- File:
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
- Lines: 106-110
Please ensure that all calls to this method are updated accordingly.
Analysis chain
Verify the function usage for the updated signature.
The
setConfig
method now includesappId
as a parameter. Ensure all calls to this method are updated accordingly.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `setConfig` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type java -A 5 $'setConfig'Length of output: 10705
Script:
#!/bin/bash # Description: Verify if the setConfig method in ConfigService.java includes the new appId parameter. # Test: Search for the setConfig method usage in ConfigService.java. Expect: Occurrences of the new signature with appId. rg --type java -A 5 'setConfig' apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.javaLength of output: 940
80-82
: Update calls toConfigService.getConfig
to use the new signature.The
getConfig
method now includesappId
as a parameter. The following instances still use the old signature and need to be updated:
apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiWhileCacheDirSpecifiedTest.java
apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/integration/ConfigIntegrationTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/integration/ConfigServiceTimeoutIntegrationTest.java
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java
apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLoader.java
Please update these instances to use the new method signature that includes
appId
.Analysis chain
Verify the function usage for the updated signature.
The
getConfig
method now includesappId
as a parameter. Ensure all calls to this method are updated accordingly.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `getConfig` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type java -A 5 $'getConfig'Length of output: 149777
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (1)
102-104
: Update all instances ofonRepositoryChange
to the new signature.The following instances of
onRepositoryChange
still use the old signature withoutappId
. Please update them to includeappId
:
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java
:
- Line 1:
simpleConfig.onRepositoryChange(TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean1.SPECIAL_NAMESPACE, properties);
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderAutoUpdateTest.java
:
- Line 1:
config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties);
- Line 2:
config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties);
- Line 3:
config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties);
- Line 4:
config.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties);
- Line 5:
applicationConfig.onRepositoryChange(ConfigConsts.NAMESPACE_APPLICATION, newProperties);
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java
:
- Line 1:
configFile.onRepositoryChange(someNamespace, anotherProperties);
- Line 2:
configFile.onRepositoryChange(someNamespace, someProperties);
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
:
- Line 1:
defaultConfig.onRepositoryChange(someNamespace, anotherProperties);
- Line 2:
defaultConfig.onRepositoryChange(someNamespace, someProperties);
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepositoryTest.java
:
- Line 1:
verify(someListener, times(1)).onRepositoryChange(someNamespaceName, anotherProperties);
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
:
- Line 1:
verify(someListener, times(1)).onRepositoryChange(eq(someNamespace), captor.capture());
- Line 2:
verify(someListener, times(1)).onRepositoryChange(any(String.class), any(Properties.class));
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java
:
- Line 1:
configFile.onRepositoryChange(someNamespace, anotherProperties);
- Line 2:
configFile.onRepositoryChange(someNamespace, someProperties);
Please review and update these instances to ensure consistency with the new method signature.
Analysis chain
Verify the function usage for the updated signature.
The
onRepositoryChange
method now includesappId
as a parameter. Ensure all calls to this method are updated accordingly.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `onRepositoryChange` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type java -A 5 $'onRepositoryChange'Length of output: 63294
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (57)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (1 hunks)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (7 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEvent.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/JsonConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PlainTextConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepository.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/TxtConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/XmlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YmlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigFileChangeEvent.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactory.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactoryManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigRegistry.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/AutoUpdateConfigChangeListener.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValue.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java (30 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java (9 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (9 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/TxtConfigFileTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/YamlConfigFileTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryFileCachePropertyTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java (3 hunks)
Files not processed due to max files limit (14)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderAutoUpdateTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderAutoUpdateTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/CachedCompositePropertySourceTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java
- apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/ApolloTestingServer.java
- apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiWhileCacheDirSpecifiedTest.java
Files skipped from review due to trivial changes (1)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/AutoUpdateConfigChangeListener.java
Additional comments not posted (200)
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (1)
1-29
: Review of the newMultipleConfig
annotation
Annotation Purpose:
TheMultipleConfig
annotation is designed to supplement@EnableApolloConfig
for handling multipleappId
configurations.Attributes:
appId
: This attribute is correctly defined to hold a single application ID.namespaces
: This attribute is correctly defined to hold multiple namespaces.secret
: This attribute is correctly defined with a default value and an example in the documentation.The provided code looks good and correctly defines the annotation and its attributes.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/TxtConfigFile.java (1)
23-24
: Constructor modification to includeappId
The constructor now includes the
appId
parameter, which is correctly passed to the superclass constructor.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YmlConfigFile.java (1)
25-26
: Constructor modification to includeappId
The constructor now includes the
appId
parameter, which is correctly passed to the superclass constructor.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/XmlConfigFile.java (1)
25-27
: Constructor modification to includeappId
The constructor now includes the
appId
parameter, which is correctly passed to the superclass constructor.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/JsonConfigFile.java (1)
25-27
: Constructor change to includeappId
looks good.The addition of
appId
in the constructor and passing it to the superclass is appropriate.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactoryManager.java (1)
30-37
: New method to get the config factory byappId
looks good.The new method
getFactory
withappId
parameter is consistent with the existing method and extends functionality appropriately.apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java (1)
30-31
: Overridden method to includeappId
looks good.The overridden method
createRepositoryConfig
now includesappId
, ensuringPureApolloConfig
is created correctly.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java (1)
31-38
: New method to handle repository changes byappId
looks good.The new method
onRepositoryChange
withappId
parameter is consistent with the existing method and extends functionality appropriately.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PlainTextConfigFile.java (1)
27-28
: Constructor change approved.The constructor now includes
appId
, aligning with the PR objectives of addingappId
to configurations.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigRegistry.java (2)
33-41
: Methodregister
change approved.The method now includes
appId
, aligning with the PR objectives of addingappId
to configurations.
50-57
: MethodgetFactory
change approved.The method now includes
appId
, aligning with the PR objectives of addingappId
to configurations.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactory.java (2)
35-43
: Methodcreate
change approved.The method now includes
appId
, aligning with the PR objectives of addingappId
to configurations.
51-57
: MethodcreateConfigFile
change approved.The method now includes
appId
, aligning with the PR objectives of addingappId
to configurations.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEvent.java (1)
44-46
: Constructor change approved.The constructor now includes
appId
, aligning with the PR objectives of addingappId
to configurations.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/TxtConfigFileTest.java (4)
34-34
: AddsomeAppId
field.The
someAppId
field is added to the test class to facilitate testing the newappId
parameter in theTxtConfigFile
class.
41-41
: InitializesomeAppId
insetUp
method.The
someAppId
variable is initialized in thesetUp
method to be used in the test cases.
54-54
: UpdateTxtConfigFile
instantiation to includeappId
.The instantiation of
TxtConfigFile
is updated to include the newappId
parameter, ensuring the test reflects the updated constructor.
57-57
: Add assertion forappId
inTxtConfigFile
.An assertion is added to verify that the
appId
is correctly set in theTxtConfigFile
instance.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (2)
34-34
: AddgetConfig
method withappId
.A new method
getConfig
is added to theConfigManager
interface to retrieve configuration instances based onappId
andnamespace
.
41-41
: AddgetConfigFile
method withappId
.A new method
getConfigFile
is added to theConfigManager
interface to retrieve configuration file instances based onappId
,namespace
, andconfigFileFormat
.apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1)
38-38
: AddgetAppId
method.A new method
getAppId
is added to theConfigFile
interface to retrieve theappId
of the configuration file instance.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (5)
22-22
: ImportConfigUtil
.The
ConfigUtil
class is imported to facilitate retrieving theappId
in thegetFactory
method.
33-34
: Addm_configUtil
field.A new field
m_configUtil
is added to store theConfigUtil
instance, which is used to retrieve theappId
.
37-37
: Initializem_configUtil
in constructor.The
m_configUtil
field is initialized in the constructor to ensure it is available for use in thegetFactory
method.
42-43
: UpdategetFactory
method to useappId
.The
getFactory
method is updated to retrieve theappId
usingm_configUtil
and delegate to the overloadedgetFactory
method withappId
andnamespace
.
45-45
: Add overloadedgetFactory
method withappId
.An overloaded
getFactory
method is added to handle retrieving configuration factories based onappId
andnamespace
.apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigFileChangeEvent.java (3)
26-26
: Addition ofappId
field.The new field
appId
has been introduced to store the application ID associated with the config file change event. This change aligns with the PR objective to support multipleappId
configurations.
41-43
: Constructor update to includeappId
.The constructor now includes
appId
as a parameter to initialize the new field. This change ensures that each config file change event is associated with a specific application ID.
69-70
: Update totoString()
method to includeappId
.The
toString()
method now includes theappId
field in its output. This change ensures that the string representation of the config file change event includes the application ID.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (3)
39-39
: Usage ofTables.synchronizedTable
.The
m_instances
field is now initialized usingTables.synchronizedTable
to ensure thread safety. This change is crucial for concurrent access to the configuration instances.
47-48
: Update toregister
method to includeappId
.The
register
method now includesappId
as a parameter, and the existing method delegates to the new method withappId
. This change ensures that configurations are registered with a specific application ID.
61-62
: Update togetFactory
method to includeappId
.The
getFactory
method now includesappId
as a parameter, and the existing method delegates to the new method withappId
. This change ensures that the correct configuration factory is retrieved based on the application ID.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepository.java (1)
46-46
: Update tofireRepositoryChange
method call to includeappId
.The
fireRepositoryChange
method call now includesappId
as a parameter. This change ensures that repository changes are correctly associated with the specific application ID.apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (3)
28-28
: Addition ofappId
field.The new field
appId
has been introduced to store the application ID associated with the config change event. This change aligns with the PR objective to support multipleappId
configurations.
36-38
: Constructor update to includeappId
.The constructor now includes
appId
as a parameter to initialize the new field. This change ensures that each config change event is associated with a specific application ID.
83-85
: Addition ofgetAppId
method.The new
getAppId
method provides access to theappId
field. This change is necessary to retrieve the application ID associated with the config change event.apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (1)
37-39
: Constructor updated to includeappId
.The constructor now includes the
appId
parameter, which is passed to the superclass. Ensure that theappId
is correctly utilized in the superclass and throughout the configuration management logic.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (1)
66-69
: MethodfireRepositoryChange
updated to includeappId
.The
fireRepositoryChange
method now includes theappId
parameter. Ensure that all listeners handle theappId
correctly and that this change is consistently propagated throughout the repository change notification logic.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1)
72-76
: New parametermultipleConfig
added.The
multipleConfig
parameter supports additionalappId
and namespace configurations. Ensure this parameter is correctly utilized in the annotation processing logic and that it does not interfere with existing configurations.apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (2)
27-27
: New fieldappId
added.The
appId
field is now part of theConfigChange
class. Ensure this field is correctly utilized in all relevant methods and that it is properly initialized.
36-45
: Constructor updated to includeappId
.The constructor now includes the
appId
parameter. Ensure that this parameter is correctly utilized in the initialization logic and that it is consistently propagated throughout the configuration change management logic.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java (1)
39-41
: Constructor change: Initialization ofappId
looks good.The constructor correctly passes
appId
to the superclass.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java (1)
39-40
: Constructor change: Initialization ofappId
looks good.The constructor correctly passes
appId
to the superclass.apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryFileCachePropertyTest.java (3)
41-46
: Test setup: Initialization ofappId
andnamespace
looks good.The test setup correctly initializes
someAppId
andsomeNamespace
.
58-62
: Test method: Handling ofappId
looks good.The test method correctly passes
appId
in the method calls and assertions.
70-74
: Test method: Handling ofappId
looks good.The test method correctly passes
appId
in the method calls and assertions.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java (1)
74-77
: Test method: Handling ofappId
looks good.The test method correctly passes
appId
in theConfigChange
andfireConfigChange
method calls.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (3)
61-73
: Concurrency handling review.The method uses
computeIfAbsent
andsynchronized
blocks for concurrency control. This approach is correct, but ensure that the lock object is not excessively contended.
Line range hint
86-119
:
Concurrency handling review.The method uses
computeIfAbsent
andsynchronized
blocks for concurrency control. This approach is correct, but ensure that the lock object is not excessively contended.
57-58
: Verify the function usage for the updated signature.The
getConfig
method now includesappId
as a parameter. Ensure all calls to this method are updated accordingly.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValue.java (1)
131-131
: LGTM!The
isTargetBeanValid
method correctly checks if the bean reference is still valid.apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (1)
116-119
: Verify the function usage for the updated signature.The
setConfigFactory
method now includesappId
as a parameter. Ensure all calls to this method are updated accordingly.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (2)
Line range hint
106-126
:
Concurrency handling review.The method uses
synchronized
blocks for concurrency control. This approach is correct, but ensure that the lock object is not excessively contended.
57-58
: Verify the constructor usage for the updated signature.The
SimpleConfig
constructor now includesappId
as a parameter. Ensure all calls to this constructor are updated accordingly.Verification successful
Verified the constructor usage for the updated signature.
The
SimpleConfig
constructor now includesappId
as a parameter, and all calls to this constructor have been updated accordingly.
- All instances of
SimpleConfig
in the codebase correctly use the new constructor signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `SimpleConfig` match the new signature. # Test: Search for the constructor usage. Expect: Only occurances of the new signature. rg --type java -A 5 $'SimpleConfig'Length of output: 46034
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java (6)
Line range hint
42-51
:
LGTM! Initialization ofsomeAppId
andsomeNamespace
.The initialization of
someAppId
andsomeNamespace
in thesetUp
method is correct.
67-67
: LGTM! Integration ofsomeAppId
intestWhenHasContent
.The integration of
someAppId
in theJsonConfigFile
constructor and the subsequent assertions are correct.
80-80
: LGTM! Integration ofsomeAppId
intestWhenHasNoContent
.The integration of
someAppId
in theJsonConfigFile
constructor and the subsequent assertions are correct.
90-90
: LGTM! Integration ofsomeAppId
intestWhenConfigRepositoryHasError
.The integration of
someAppId
in theJsonConfigFile
constructor and the subsequent assertions are correct.
Line range hint
110-121
:
LGTM! Integration ofsomeAppId
intestOnRepositoryChange
.The integration of
someAppId
in theJsonConfigFile
constructor and theonRepositoryChange
method is correct. The test verifies the behavior correctly.
139-145
: LGTM! Integration ofsomeAppId
intestWhenConfigRepositoryHasErrorAndThenRecovered
.The integration of
someAppId
in theJsonConfigFile
constructor and theonRepositoryChange
method is correct. The test verifies the recovery behavior correctly.apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java (13)
101-105
: LGTM! Addition ofcreate
method withappId
inMockConfigRegistry
.The addition of the
create
method with theappId
parameter in theMockConfigRegistry
class is correct.
111-115
: LGTM! Addition ofcreateConfigFile
method withappId
inMockConfigRegistry
.The addition of the
createConfigFile
method with theappId
parameter in theMockConfigRegistry
class is correct.
123-126
: LGTM! Addition ofregister
method withappId
inMockConfigRegistry
.The addition of the
register
method with theappId
parameter in theMockConfigRegistry
class is correct.
136-139
: LGTM! Addition ofgetFactory
method withappId
inMockConfigRegistry
.The addition of the
getFactory
method with theappId
parameter in theMockConfigRegistry
class is correct.
148-152
: LGTM! Addition ofcreate
method withappId
inSomeConfigFactory
.The addition of the
create
method with theappId
parameter in theSomeConfigFactory
class is correct.
158-161
: LGTM! Addition ofcreateConfigFile
method withappId
inSomeConfigFactory
.The addition of the
createConfigFile
method with theappId
parameter in theSomeConfigFactory
class is correct.
170-174
: LGTM! Addition ofcreate
method withappId
inAnotherConfigFactory
.The addition of the
create
method with theappId
parameter in theAnotherConfigFactory
class is correct.
180-183
: LGTM! Addition ofcreateConfigFile
method withappId
inAnotherConfigFactory
.The addition of the
createConfigFile
method with theappId
parameter in theAnotherConfigFactory
class is correct.
116-119
: LGTM! Addition ofgetFactory
method withappId
inMockConfigFactoryManager
.The addition of the
getFactory
method with theappId
parameter in theMockConfigFactoryManager
class is correct.
139-142
: LGTM! Addition ofcreate
method withappId
inMockConfigFactoryManager
.The addition of the
create
method with theappId
parameter in theMockConfigFactoryManager
class is correct.
Line range hint
144-146
:
LGTM! Addition ofcreateConfigFile
method withappId
inMockConfigFactoryManager
.The addition of the
createConfigFile
method with theappId
parameter in theMockConfigFactoryManager
class is correct.
171-173
: LGTM! Addition ofcreateConfigFile
method withappId
inMockConfigFactoryManager
.The addition of the
createConfigFile
method with theappId
parameter in theMockConfigFactoryManager
class is correct.
177-180
: LGTM! Addition ofgetFactory
method withappId
inMockConfigFactoryManager
.The addition of the
getFactory
method with theappId
parameter in theMockConfigFactoryManager
class is correct.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (4)
61-63
: LGTM! Integration ofappId
in the constructor.The integration of the
appId
parameter in the constructor of theAbstractConfigFile
class is correct.
85-88
: LGTM! Implementation ofgetAppId
.The implementation of the
getAppId
method in theAbstractConfigFile
class is correct.
99-100
: LGTM! Integration ofappId
inonRepositoryChange
.The integration of the
appId
parameter in theonRepositoryChange
method of theAbstractConfigFile
class is correct.
Line range hint
102-125
:
LGTM! Integration ofappId
in the synchronizedonRepositoryChange
method.The integration of the
appId
parameter in the synchronizedonRepositoryChange
method of theAbstractConfigFile
class is correct.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java (3)
46-54
: LGTM! Initialization ofsomeAppId
.The initialization of
someAppId
in thesetUp
method is correct.
116-119
: LGTM! Addition ofgetFactory
method withappId
inMockConfigFactoryManager
.The addition of the
getFactory
method with theappId
parameter in theMockConfigFactoryManager
class is correct.
139-142
: LGTM! Addition ofcreate
method withappId
inMockConfigFactoryManager
.The addition of the
create
method with theappId
parameter in theMockConfigFactoryManager
class is correct.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java (3)
Line range hint
52-62
: LGTM! Initialization and mocking are correctly done.The
setUp
function correctly initializes thesomeAppId
variable and mocks theconfigRepository
andpropertiesFactory
.
91-93
: LGTM! The test case correctly verifies the functionality.The
testGetProperty
test case correctly verifies thegetProperty
andgetSourceType
methods of theSimpleConfig
class.
Line range hint
138-166
: LGTM! The test case correctly verifies the functionality.The
testOnRepositoryChange
test case correctly verifies theonRepositoryChange
method of theSimpleConfig
class.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java (2)
56-77
: LGTM! The method correctly handles multipleappId
configurations.The
registerBeanDefinitions
method correctly handles multipleappId
configurations and sets the secret property.
106-112
: LGTM! The method correctly resolves the secret using the environment.The
resolveSecret
method correctly resolves the secret using the environment.apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (4)
62-66
: LGTM! The test case correctly verifies the functionality.The
testHackConfig
test case correctly verifies thegetAppConfig
method of theConfigService
class.
89-91
: LGTM! The test case correctly verifies the functionality.The
testMockConfigFactory
test case correctly verifies thegetConfig
method of theConfigService
class.
102-103
: LGTM! The test case correctly verifies the functionality.The
testMockConfigFactoryForConfigFile
test case correctly verifies thegetConfigFile
method of theConfigService
class.
197-212
: LGTM! The methods correctly createConfig
andConfigFile
instances.The
MockConfigFactory
class methods correctly createConfig
andConfigFile
instances with theappId
parameter.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java (3)
68-72
: LGTM! The test case correctly verifies the functionality.The
testFireConfigChange_cannot_notify
test case correctly verifies thefireConfigChange
method of theAbstractConfig
class.
111-112
: LGTM! The test case correctly verifies the functionality.The
testFireConfigChange_event_notify_once
test case correctly verifies thefireConfigChange
method of theAbstractConfig
class.
156-158
: LGTM! The test case correctly verifies the functionality.The
testFireConfigChange_changes_notify_once
test case correctly verifies thefireConfigChange
method of theAbstractConfig
class.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (4)
99-100
: LGTM!The changes correctly integrate the
appId
parameter.
104-118
: LGTM!The changes correctly integrate the
appId
parameter.
124-138
: LGTM!The changes correctly integrate the
appId
parameter.
68-69
: Verify the usage ofcreate
method withappId
.Ensure that all calls to the
create
method are updated to use the new method withappId
where appropriate.Verification successful
Verify the usage of
create
method withappId
.The
create
method with theappId
parameter is correctly used in the codebase. The instances of the new method signature have been found and verified.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to the `create` method with `appId`. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'create($_, $_)'Length of output: 38
Script:
#!/bin/bash # Description: Verify all calls to the `create` method with `appId`. # Test: Search for the function usage. Expect: Occurrences of the new signature. rg --type java -A 5 -w 'create'Length of output: 96565
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java (8)
60-60
: LGTM!The initialization of
someAppId
is correct and integrates well with existing code.
85-85
: LGTM!The changes correctly integrate the
appId
parameter.
97-97
: LGTM!The changes correctly integrate the
appId
parameter.
107-107
: LGTM!The changes correctly integrate the
appId
parameter.
123-123
: LGTM!The changes correctly integrate the
appId
parameter.
162-162
: LGTM!The changes correctly integrate the
appId
parameter.
182-182
: LGTM!The changes correctly integrate the
appId
parameter.
197-197
: LGTM!The changes correctly integrate the
appId
parameter.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (6)
68-70
: LGTM!The initialization of
configUtil
is correct and integrates well with existing code.
73-74
: LGTM!The changes correctly integrate the
appId
parameter.
76-79
: LGTM!The changes correctly integrate the
appId
parameter.
102-118
: LGTM!The changes correctly integrate the
appId
parameter.
176-176
: LGTM!The reset logic is correct and integrates well with existing code.
Line range hint
204-208
: LGTM!The changes correctly integrate the
appId
parameter.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java (7)
122-122
: LGTM!The changes correctly integrate the
appId
parameter.
122-122
: LGTM!The changes correctly integrate the
appId
parameter.
138-138
: LGTM!The changes correctly integrate the
appId
parameter.
150-150
: LGTM!The changes correctly integrate the
appId
parameter.
164-171
: LGTM!The changes correctly integrate the
appId
parameter.
Line range hint
187-208
: LGTM!The changes correctly integrate the
appId
parameter.
204-204
: LGTM!The changes correctly integrate the
appId
parameter.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java (5)
52-52
: InitializesomeAppId
correctly.Ensure that the
someAppId
variable is correctly initialized and used in the tests.Also applies to: 61-61
88-88
: PassappId
correctly to constructor.Ensure that the
appId
parameter is correctly passed to theXmlConfigFile
constructor.
100-100
: PassappId
correctly to constructor.Ensure that the
appId
parameter is correctly passed to theXmlConfigFile
constructor.
110-110
: PassappId
correctly to constructor.Ensure that the
appId
parameter is correctly passed to theXmlConfigFile
constructor.
126-126
: PassappId
correctly to constructor and method.Ensure that the
appId
parameter is correctly passed to theXmlConfigFile
constructor andonRepositoryChange
method.Also applies to: 143-143
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java (1)
121-121
: InitializesomeAppId
correctly.Ensure that the
someAppId
variable is correctly initialized and used in the integration tests.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/YamlConfigFileTest.java (5)
42-42
: InitializesomeAppId
correctly.Ensure that the
someAppId
variable is correctly initialized and used in the tests.Also applies to: 55-55
89-89
: PassappId
correctly to constructor.Ensure that the
appId
parameter is correctly passed to theYamlConfigFile
constructor.
115-115
: PassappId
correctly to constructor.Ensure that the
appId
parameter is correctly passed to theYamlConfigFile
constructor.
129-129
: PassappId
correctly to constructor.Ensure that the
appId
parameter is correctly passed to theYamlConfigFile
constructor.
203-203
: PassappId
correctly to constructor and method.Ensure that the
appId
parameter is correctly passed to theYamlConfigFile
constructor andonRepositoryChange
method.Also applies to: 215-215
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (6)
52-52
: Add and initializem_appId
field correctly.Ensure that the
appId
parameter is correctly passed and assigned to them_appId
field.Also applies to: 66-71
139-150
: OverloadonRepositoryChange
correctly.Ensure that the
appId
parameter is correctly passed and utilized in the method.
Line range hint
151-193
: Ensure existing logic remains intact.The
sync
method does not involve changes related toappId
. Ensure that the existing logic remains intact.
Line range hint
194-208
: Ensure existing logic remains intact.The
trySyncFromUpstream
method does not involve changes related toappId
. Ensure that the existing logic remains intact.
Line range hint
209-222
: Ensure existing logic remains intact.The
updateFileProperties
method does not involve changes related toappId
. Ensure that the existing logic remains intact.
142-150
: OverloadonRepositoryChange
correctly.Ensure that the
appId
parameter is correctly passed and utilized in the method.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (6)
49-49
: AddappId
initialization.The new
m_appId
field is correctly initialized in the constructor.
224-225
: UpdateonRepositoryChange
method to includeappId
.The
onRepositoryChange
method has been overloaded to includeappId
. Ensure it is called with the correct parameters.
Line range hint
227-245
:
Add newonRepositoryChange
method withappId
.The new
onRepositoryChange
method correctly includes theappId
parameter. Ensure consistency in its usage.
Line range hint
309-321
:
Load resource config usingappId
.The
loadFromResource
method now includesappId
in the resource path. Ensure the resource files follow this naming convention.
258-258
: UpdatecalcPropertyChanges
call to includeappId
.The
calcPropertyChanges
method is now called withappId
. Ensure the method signature matches this change.Verification successful
Method signature already includes
appId
.The
calcPropertyChanges
method signature inAbstractConfig.java
already includesappId
as a parameter, which matches the suggested change.
calcPropertyChanges
method definition:List<ConfigChange> calcPropertyChanges(String appId, String namespace, Properties previous, Properties current)Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the method signature of `calcPropertyChanges` to include `appId`. # Test: Search for the method definition. Expect: Signature includes `appId`. rg --type java $'List<ConfigChange> calcPropertyChanges'Length of output: 236
61-68
: Constructor updated to includeappId
.The constructor has been updated to include the
appId
parameter. Ensure all calls to this constructor are updated accordingly.Verification successful
Constructor updated to include
appId
successfully.All calls to the
DefaultConfig
constructor have been updated to include theappId
parameter as required.
- Verified instances in:
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryFileCachePropertyTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `DefaultConfig` match the new signature. # Test: Search for the constructor usage. Expect: Only occurrences with the new signature. rg --type java -A 5 $'new DefaultConfig'Length of output: 26924
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5)
75-75
: AddappId
initialization.The new
m_appId
field is correctly initialized in the constructor.
191-194
: UpdateloadApolloConfig
to usem_appId
.The
loadApolloConfig
method now usesm_appId
. Ensure the logic correctly handles theappId
.
336-336
: Updatesubmit
call to includeappId
.The
submit
method is now called withappId
. Ensure consistency in its usage.
93-97
: Constructor updated to includeappId
.The constructor has been updated to include the
appId
parameter. Ensure all calls to this constructor are updated accordingly.Verification successful
Constructor calls updated to include
appId
.All instances of the
RemoteConfigRepository
constructor have been updated to include theappId
parameter:
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `RemoteConfigRepository` match the new signature. # Test: Search for the constructor usage. Expect: Only occurrences with the new signature. rg --type java -A 5 $'new RemoteConfigRepository'Length of output: 8134
160-160
: UpdatefireRepositoryChange
call to includeappId
.The
fireRepositoryChange
method is now called withappId
. Ensure the method signature matches this change.Verification successful
The method
fireRepositoryChange
inAbstractConfigRepository.java
does includeappId
in its signature:protected void fireRepositoryChange(String appId, String namespace, Properties newProperties) {The call to
fireRepositoryChange
inRemoteConfigRepository.java
appears to correctly passm_appId
as the first parameter:this.fireRepositoryChange(m_appId, m_namespace, this.getConfig());To ensure everything is correctly implemented, let's verify the definition of
m_appId
withinRemoteConfigRepository.java
.
Verified: The
fireRepositoryChange
method call inRemoteConfigRepository.java
correctly includesappId
as per the method signature inAbstractConfigRepository.java
.
- The
m_appId
is properly defined and initialized in theRemoteConfigRepository
class.- The call to
fireRepositoryChange
correctly passesm_appId
as the first parameter.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the method signature of `fireRepositoryChange` to include `appId`. # Test: Search for the method definition. Expect: Signature includes `appId`. rg --type java $'protected void fireRepositoryChange'Length of output: 247
Script:
#!/bin/bash # Description: Verify the definition and usage of `m_appId` in RemoteConfigRepository.java # Search for the definition of `m_appId` in RemoteConfigRepository.java rg 'm_appId' --type java -A 5 # Search for the constructor of `RemoteConfigRepository` to see how `m_appId` is initialized rg 'public RemoteConfigRepository' --type java -A 10Length of output: 30555
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (9)
71-73
: UseConcurrentHashMap
andTable
for managing configurations.The use of
ConcurrentHashMap
andTable
improves concurrency handling. Ensure thread safety throughout the code.
106-112
: Updatesubmit
method to includeappId
.The
submit
method is now called withappId
. Ensure consistency in its usage.
Line range hint
115-141
:
UpdatestartLongPolling
method to includeappId
.The
startLongPolling
method is now called withappId
. Ensure consistency in its usage.
172-172
: Update URL assembly to includeappId
notifications.The
assembleLongPollRefreshUrl
method now includesappId
in the notifications. Ensure the URL format is correct.
190-193
: Updatenotify
method to includeappId
.The
notify
method is now called withappId
. Ensure consistency in its usage.
211-211
: Update error logging to includeappId
.The error logging now includes
appId
. This change improves debugging and traceability.
223-236
: Updatenotify
method to includeappId
.The
notify
method is now called withappId
. Ensure consistency in its usage.
247-260
: UpdateupdateNotifications
method to includeappId
.The
updateNotifications
method is now called withappId
. Ensure consistency in its usage.
286-287
: UpdateassembleNamespaces
method to includeappId
.The
assembleNamespaces
method now includesappId
. Ensure consistency in its usage.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (8)
148-148
: AddappId
parameter in test setup.The
RemoteConfigRepository
is now instantiated withappId
in the test setup. Ensure consistency in all tests.
174-174
: Update test to includeappId
parameter.The test
testLoadConfigWithOrderedProperties
has been updated to includeappId
. Ensure test coverage for the new parameter.
211-211
: Update test to includeappId
parameter.The test
testLoadConfigWithAccessKeySecret
has been updated to includeappId
. Ensure test coverage for the new parameter.
224-224
: Update test to includeappId
parameter.The test
testGetRemoteConfigWithServerError
has been updated to includeappId
. Ensure test coverage for the new parameter.
237-237
: Update test to includeappId
parameter.The test
testGetRemoteConfigWithNotFount
has been updated to includeappId
. Ensure test coverage for the new parameter.
Line range hint
254-265
:
Update test to includeappId
parameter.The test
testRepositoryChangeListener
has been updated to includeappId
. Ensure test coverage for the new parameter.
290-290
: Update test to includeappId
parameter.The test
testLongPollingRefresh
has been updated to includeappId
. Ensure test coverage for the new parameter.
342-342
: Update test to includeappId
parameter.The test
testAssembleQueryConfigUrl
has been updated to includeappId
. Ensure test coverage for the new parameter.apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (1)
513-518
: LGTM! Verify test coverage for the new method.The
getAppSecret
method correctly retrieves the app secret based on the givenappId
. Ensure that there are tests covering this new functionality.Verification successful
Indirect test coverage for
getAppSecret
is confirmed.The method
getAppSecret
is indirectly tested through various test cases inRemoteConfigRepositoryTest.java
, such astestLoadConfigWithAccessKeySecret
. This ensures that the functionality is adequately covered.
RemoteConfigRepositoryTest.java
: Contains tests that indirectly verify the behavior ofgetAppSecret
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of tests for the getAppSecret method. # Test: Search for test cases. Expect: Test cases for getAppSecret method. rg --type java -A 5 'getAppSecret'Length of output: 2449
Script:
#!/bin/bash # Description: Search for test classes related to RemoteConfigRepository and RemoteConfigLongPollService to check if getAppSecret is indirectly tested. # Find test files for RemoteConfigRepository rg --type java -l 'RemoteConfigRepository' | grep -i 'test' # Find test files for RemoteConfigLongPollService rg --type java -l 'RemoteConfigLongPollService' | grep -i 'test'Length of output: 704
Script:
#!/bin/bash # Description: Check if getAppSecret is tested indirectly in the test files. # Search for invocations of getAppSecret in RemoteConfigRepositoryTest.java rg --type java 'getAppSecret' apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java # Search for invocations of getAppSecret in RemoteConfigLongPollServiceTest.java rg --type java 'getAppSecret' apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.javaLength of output: 258
Script:
#!/bin/bash # Description: Examine the contents of the test files to confirm if getAppSecret is indirectly tested. # Display the contents of RemoteConfigRepositoryTest.java cat apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java # Display the contents of RemoteConfigLongPollServiceTest.java cat apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.javaLength of output: 40892
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (2)
457-465
: LGTM! The method update is consistent.The
fireConfigChange
method now correctly includesappId
in the change event handling logic.
Line range hint
570-605
:
LGTM! The method update is consistent.The
calcPropertyChanges
method now correctly includesappId
in the property change calculation logic.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (5)
136-136
: LGTM! The test case update is consistent.The
testSubmitLongPollNamespaceWith304Response
method now correctly includesappId
as a parameter.
187-187
: LGTM! The test case update is consistent.The
testSubmitLongPollNamespaceWith200Response
method now correctly includesappId
as a parameter.
249-249
: LGTM! The test case update is consistent.The
testSubmitLongPollNamespaceWithAccessKeySecret
method now correctly includesappId
as a parameter.
320-323
: LGTM! The test case update is consistent.The
testSubmitLongPollMultipleNamespaces
method now correctly includesappId
as a parameter.
391-392
: LGTM! The test case update is consistent.The
testSubmitLongPollMultipleNamespacesWithMultipleNotificationsReturned
method now correctly includesappId
as a parameter.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java (30)
74-74
: InitializesomeAppId
fieldThe
someAppId
field is introduced to support the new constructor signature ofDefaultConfig
.
95-95
: SetsomeAppId
in setup methodInitializing
someAppId
in the setup method ensures it's available for all tests.
150-150
: Update constructor call to includeappId
The constructor of
DefaultConfig
is updated to includeappId
. Ensure all instances are updated accordingly.
183-183
: Update constructor call to includeappId
Consistently updating the constructor to include
appId
.
202-202
: Update constructor call to includeappId
Ensure consistency in constructor updates.
225-225
: Update constructor call to includeappId
Constructor update is consistent with the new signature.
256-256
: Update constructor call to includeappId
Constructor update aligns with the new
appId
parameter.
288-288
: Update constructor call to includeappId
Constructor updated to match new signature.
323-323
: Update constructor call to includeappId
Constructor update is consistent with the new signature.
346-346
: Update constructor call to includeappId
Constructor update aligns with the new
appId
parameter.
369-369
: Update constructor call to includeappId
Constructor updated to match new signature.
392-392
: Update constructor call to includeappId
Constructor update is consistent with the new signature.
415-415
: Update constructor call to includeappId
Constructor update aligns with the new
appId
parameter.
438-438
: Update constructor call to includeappId
Constructor updated to match new signature.
461-461
: Update constructor call to includeappId
Constructor update is consistent with the new signature.
485-485
: Update constructor call to includeappId
Constructor update aligns with the new
appId
parameter.
521-521
: Update constructor call to includeappId
Constructor updated to match new signature.
547-547
: Update constructor call to includeappId
Constructor update is consistent with the new signature.
577-577
: Update constructor call to includeappId
Constructor update aligns with the new
appId
parameter.
596-596
: Update constructor call to includeappId
Constructor updated to match new signature.
614-614
: Update constructor call to includeappId
Constructor update is consistent with the new signature.
652-652
: Update constructor call to includeappId
Constructor update aligns with the new
appId
parameter.
719-719
: UpdateConfigChangeEvent
constructor to includeappId
Constructor update is consistent with the new signature.
745-745
: Update constructor call to includeappId
Constructor updated to match new signature.
805-805
: Update constructor call to includeappId
Constructor update aligns with the new
appId
parameter.
840-840
: Update constructor call to includeappId
Constructor updated to match new signature.
867-867
: Update constructor call to includeappId
Constructor update is consistent with the new signature.
880-880
: Update constructor call to includeappId
Constructor update aligns with the new
appId
parameter.
900-900
: Update constructor call to includeappId
Constructor updated to match new signature.
926-926
: Update constructor call to includeappId
Constructor update is consistent with the new signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (9 hunks)
Files skipped from review as they are similar to previous changes (3)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
Additional comments not posted (8)
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (8)
30-31
: Imports approved.The new imports for
HashBasedTable
andTable
from Guava are necessary for the changes in the data structure to support theappId
parameter.
64-64
: Field type change approved.The
CONFIG_REGISTRY
field type change toTable<String, String, Config>
is necessary to support the newappId
parameter.
90-97
: Method update approved.The
prepareConfig
method update to include theappId
parameter ensures that configurations can be prepared for specific application IDs.
118-124
: Method update approved.The
prepareYamlConfigFile
method update to include theappId
parameter ensures that YAML configuration files can be prepared for specific application IDs.
166-167
: Method update approved.The
mockConfig
method update to include theappId
parameter ensures that configurations can be mocked for specific application IDs.
183-188
: Method update approved.The
doSetUp
method update to include setup forMockConfigUtil
ensures that the configuration utility can be properly mocked for testing.
Line range hint
206-225
:
Class update approved.The
MockConfigManager
class update to include methods with theappId
parameter ensures that the mock configuration manager can handle configurations for specific application IDs.
246-248
: Class update approved.The
MockConfigUtil
class update to include thegetAppId
method ensures that the mock configuration utility can provide an application ID for testing.
Thanks, it may take some time to reivew. In the meantime, could you please sign the CLA following the instructions provided by the CLA Assistant Lite bot? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (16)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (7 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (9 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/integration/ConfigIntegrationTest.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java (30 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepositoryTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (29 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java (20 hunks)
- apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/StringUtils.java (1 hunks)
Files skipped from review due to trivial changes (1)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java
Files skipped from review as they are similar to previous changes (6)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
Additional comments not posted (24)
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepositoryTest.java (3)
43-43
: Addition of appId field.The addition of the
someAppId
field aligns with the new requirement to handle multiple appIds. This change is necessary for testing configurations specific to an appId.
51-53
: Setup method updates to handle appId.The
setUp
method now initializessomeAppId
and mocks its retrieval. This is crucial for ensuring that the unit tests can simulate scenarios where different appIds are used to fetch configurations.
135-135
: Verification of repository change handling with appId.The
testOnChange
method now verifies that theonRepositoryChange
method is called with the correct appId. This ensures that the repository change events are correctly propagated with the appId context, which is essential for multi-app configurations.apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (6)
29-29
: Import addition for ConfigConsts.The addition of
ConfigConsts
import suggests usage of constants related to configuration, possibly related to appId. This is a good practice as it promotes the use of constants instead of hard-coded values.
84-84
: Modification to use appId in config repository creation.The
createConfigRepository
method is modified to acceptappId
, which is essential for creating configurations specific to an application. This change is crucial for supporting multi-tenancy.
99-99
: Local configuration repository creation with appId.The
createLocalConfigRepository
method now includesappId
in its parameters, ensuring that local configurations are associated with the correct application. This is a necessary change for maintaining the integrity of configurations across different applications.
117-119
: Creation of PropertiesCompatibleFileConfigRepository with appId.The method now correctly handles
appId
when creating aPropertiesCompatibleFileConfigRepository
. This ensures that properties files are correctly associated with their respective applications, which is vital for accurate configuration management.
136-138
: Multiple local repository creations with appId.The test now covers scenarios where multiple local repositories are created with different appIds. This is important for testing the factory's ability to handle multiple applications simultaneously.
191-204
: Namespace trimming with appId.The
checkNamespaceName
method now includes appId in its logic. This is crucial for ensuring that namespace names are correctly processed in the context of an application, preventing potential conflicts or errors in multi-tenant environments.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java (1)
109-113
: Integration of appId in ApolloConfig processing.The
processApolloConfig
method now includes logic to handleappId
. This is crucial for ensuring that configurations are fetched and injected based on the correct application identifier, aligning with the multi-tenancy requirements.apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/StringUtils.java (1)
343-345
: Addition of defaultIfBlank method.The
defaultIfBlank
method provides a default value if the input string is blank, usingappId
as the fallback. This utility method is a valuable addition, especially in configurations where default values are needed based on the application context.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (5)
49-49
: Addition of appId field.The addition of the
m_appId
field is consistent with the PR's objective to handle configurations for multiple apps. Ensure that all usages of this field are correctly implemented across the class.
61-65
: Constructor modification to include appId.The constructor now includes an
appId
parameter and initializesm_appId
. This change is necessary for supporting multiple app configurations. The methodloadFromResource
has been adapted to useappId
which is a good practice to ensure configurations are loaded per app basis.Also applies to: 68-68
224-225
: Method Overloading for onRepositoryChange.The
onRepositoryChange
method has been overloaded to include anappId
parameter. This is a crucial change to ensure that repository changes are handled per app. The logic inside the method appears to be correct and properly checks for changes before firing a configuration change event.Also applies to: 227-245
258-258
: Calculation of property changes now includes appId.The method
calcPropertyChanges
has been updated to includeappId
. This is important for correctly calculating changes per app. Ensure that this method is used consistently across the class.
Line range hint
309-321
: Resource loading adapted for appId.The method
loadFromResource
has been adapted to includeappId
in the resource path. This change ensures that app-specific configurations can be loaded. The error handling and resource stream closure are correctly implemented.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (2)
60-61
: Addition of appId constant for testing.The constant
someAppId
has been added to use across tests, ensuring consistency when testing multi-app configurations.
96-96
: Updated mockConfig calls to include appId.All
mockConfig
method calls have been updated to includeappId
. This change is necessary to ensure that the tests are aligned with the new multi-app support in the Apollo client.Also applies to: 140-141, 176-180, 218-218, 250-250, 284-284, 317-317, 353-353, 382-382, 414-414
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java (2)
63-63
: Addition of appId constant for testing.The constant
someAppId
has been added to use across tests, ensuring consistency when testing multi-app configurations.
74-74
: Updated mockConfig and mockConfigFile calls to include appId.All
mockConfig
andmockConfigFile
method calls have been updated to includeappId
. This change is necessary to ensure that the tests are aligned with the new multi-app support in the Apollo client.Also applies to: 82-82, 95-95, 111-111, 127-127, 139-139, 143-143, 161-161, 165-165, 180-180, 184-184, 199-199, 203-203, 217-217, 221-221, 235-235, 254-254, 276-276, 297-297, 315-315, 338-338, 360-360, 378-378, 409-409, 428-428, 436-436
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (4)
Line range hint
22-33
: Added imports and annotations are appropriate.The imports and the new
@MultipleConfig
annotation align with the changes made to support multipleappId
configurations. These changes are necessary for the tests to reflect the new application structure.
79-79
: Introduction ofsomeAppId
as a constant.Defining
someAppId
as a constant is a good practice for reusability and maintainability in tests. This ensures that all test cases use a consistentappId
, which is crucial for testing the new multi-app configuration feature.
114-115
: Proper use ofmockConfig
withappId
.The
mockConfig
method is correctly used with theappId
parameter to simulate configuration settings for different applications. This is key to testing the new functionality introduced in the PR.Also applies to: 117-117
133-133
: Consistent application ofappId
across various test methods.Throughout the test file, the
appId
parameter is consistently used in various contexts, ensuring that the new functionality is thoroughly tested. This includes mocks, configuration setups, and assertions. The changes are well-integrated and cover a wide range of scenarios, which is crucial for the robustness of the feature.Also applies to: 143-145, 159-162, 174-183, 195-196, 210-211, 264-264, 273-273, 283-284, 340-341, 372-372, 398-405, 437-448, 462-469, 493-499, 518-524, 539-544, 563-566, 578-578, 584-587, 594-598, 607-616, 625-625, 639-644, 651-675, 1093-1131
I have read the CLA Document and I hereby sign the CLA |
@TerryLam2010 It seems you committed the code with |
...ig-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
...src/main/java/com/ctrip/framework/apollo/spring/property/AutoUpdateConfigChangeListener.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/property/SpringValue.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (5)
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1)
73-76
: Integration ofmultipleConfigs()
Method Not EvidentThe
multipleConfigs()
method in theEnableApolloConfig
annotation is not currently utilized in the codebase. WhileEnableApolloConfig
is used in several places, particularly in test files, there is no evidence ofmultipleConfigs()
being integrated or tested. Consider reviewing the intended use cases and updating the codebase to leverage this new method if necessary.Analysis chain
LGTM! Verify the integration of
multipleConfigs()
.The addition of the
multipleConfigs()
method is well-implemented and enhances flexibility. Ensure that the integration of this method is correctly handled throughout the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of `multipleConfigs()` method across the codebase. # Test: Search for the usage of `multipleConfigs()` method. Expect: Correct integration throughout the codebase. rg --type java 'multipleConfigs\(\)'Length of output: 184
Script:
#!/bin/bash # Search for references to the EnableApolloConfig class to see if it is used elsewhere. rg --type java 'EnableApolloConfig'Length of output: 10994
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (2)
123-125
: Document the placeholder method.The
createConfigFile
method currently returns null. Consider documenting its placeholder status and any future implementation plans.+ // TODO: Implement the method or provide documentation on its intended use.
84-86
: UpdategetConfig
Method Calls to Match New SignatureThe
getConfig
method calls in the following locations still use the old signature with a singlenamespace
parameter. They need to be updated to include theappId
parameter:
apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLoader.java
apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiWhileCacheDirSpecifiedTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/integration/ConfigIntegrationTest.java
Ensure all invocations of
getConfig
are updated to use the new signature with bothappId
andnamespace
.Analysis chain
LGTM! But verify the function usage in the codebase.
The addition of
appId
togetConfig
enhances configuration specificity. Ensure that all function calls togetConfig
match the new signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `getConfig` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'getConfig\\(String\\s+appId,\\s+String\\s+namespace\\)'Length of output: 2477
Script:
#!/bin/bash # Description: Check all invocations of `getConfig` in the codebase to ensure they match the new signature. # Search for all `getConfig` calls and display surrounding context to verify parameters. rg --type java -A 2 'getConfig\('Length of output: 53637
apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java (1)
119-125
: Handle potential null value form_appId
to prevent NullPointerException.The initialization logic for
m_appId
does not guarantee a non-null value, which could lead to aNullPointerException
in thegetAccessKeySecret(String appId)
method. Consider adding a null check form_appId
before callingequals
.
- Location:
DefaultApplicationProvider.java
, methodgetAccessKeySecret(String appId)
Analysis chain
Ensure consistent access key retrieval logic.
The new method
getAccessKeySecret(String appId)
enhances flexibility by allowing access key retrieval based on app ID. However, consider handling potential null values form_appId
to preventNullPointerException
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `m_appId` is initialized before `getAccessKeySecret(String appId)` is called. # Test: Search for initialization and usage of `m_appId`. Expect: Proper initialization before usage. rg --type java 'm_appId' -A 5Length of output: 31722
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (1)
206-207
: Consider implementing appId and namespace logic.The
appIdAndNamespace
method currently returns the namespace unchanged. Consider implementing logic to combineappId
andnamespace
if needed.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (26)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (8 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (7 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigFileChangeEvent.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/build/MockInjector.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (7 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (29 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java (1 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/NullProvider.java (1 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java (1 hunks)
Files skipped from review due to trivial changes (1)
- apollo-client/src/test/java/com/ctrip/framework/apollo/build/MockInjector.java
Additional comments not posted (83)
apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java (1)
50-53
: Addition ofgetAccessKeySecret(String appId)
approved.The new method enhances the interface by providing access to the access key secret for a specific app ID. Ensure that this method is correctly implemented in all classes that implement this interface.
Verify the implementation of this method across the codebase to ensure consistency.
Verification successful
Method Implemented Consistently
The
getAccessKeySecret(String appId)
method is implemented in the following classes that implement theApplicationProvider
interface:
DefaultApplicationProvider
NullProvider
This confirms that the method has been consistently implemented across the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `getAccessKeySecret(String appId)` in classes implementing `ApplicationProvider`. # Test: Search for the method implementation. Expect: Implementations in all relevant classes. ast-grep --lang java --pattern $'class $_ implements ApplicationProvider { $$$ String getAccessKeySecret(String appId) { $$$ } $$$ }'Length of output: 146
Script:
#!/bin/bash # Find all classes implementing ApplicationProvider and check for the getAccessKeySecret method. fd -e java -x grep -H 'class .* implements ApplicationProvider' {} | cut -d: -f1 | sort -u | xargs -I {} sh -c 'echo "Checking {}"; grep -q "String getAccessKeySecret(String appId)" {} && echo "Method implemented in {}" || echo "Method not implemented in {}"'Length of output: 739
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (2)
51-58
: Addition ofgetConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
approved.The method extends configuration file retrieval capabilities by allowing specification of app ID and namespace. Ensure that this method is correctly implemented and tested.
Verify the implementation and usage of this method across the codebase.
Verification successful
Implementation and Usage Verified
The
getConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
method is implemented in theDefaultConfigManager
class and is also present in a test class, indicating it is being tested. This confirms the method's implementation and usage in the codebase. No further issues found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation and usage of `getConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)`. # Test: Search for the method implementation and usage. Expect: Implementations and usages in all relevant classes. ast-grep --lang java --pattern $'class $_ implements ConfigManager { $$$ ConfigFile getConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat) { $$$ } $$$ }'Length of output: 772
Script:
#!/bin/bash # Description: Find the implementation of `getConfigFile` method in classes implementing `ConfigManager`. # Search for classes implementing `ConfigManager` and having `getConfigFile` method. ast-grep --lang java --pattern $'class $_ implements ConfigManager { $$$ public ConfigFile getConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat); $$$ }'Length of output: 186
Script:
#!/bin/bash # Description: Find the usage of `getConfigFile` method across the codebase. # Search for usages of the `getConfigFile` method. rg 'getConfigFile\s*\(\s*String\s+appId\s*,\s*String\s+namespace\s*,\s*ConfigFileFormat\s+configFileFormat\s*\)' -A 3Length of output: 1711
35-41
: Addition ofgetConfig(String appId, String namespace)
approved.The method enhances configuration management by allowing retrieval based on both app ID and namespace. Ensure that this method is correctly implemented and tested.
Verify the implementation and usage of this method across the codebase.
Verification successful
Implementation and Usage of
getConfig(String appId, String namespace)
VerifiedThe
getConfig(String appId, String namespace)
method is implemented and used correctly across the codebase:
DefaultConfigManager
: Contains the main implementation of the method.ConfigService
: Provides a static method that delegates to theConfigManager
implementation.AbstractSpringIntegrationTest
: Used for testing purposes.These implementations ensure the method is integrated into the configuration management workflow.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation and usage of `getConfig(String appId, String namespace)`. # Test: Search for the method implementation and usage. Expect: Implementations and usages in all relevant classes. ast-grep --lang java --pattern $'class $_ implements ConfigManager { $$$ Config getConfig(String appId, String namespace) { $$$ } $$$ }'Length of output: 149
Script:
#!/bin/bash # Search for the implementation of `getConfig(String appId, String namespace)` across the codebase rg 'Config getConfig\(String appId, String namespace\)' -A 5Length of output: 2466
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1)
38-44
: Addition of default methodgetAppId()
approved.The method provides a way to retrieve the app ID associated with the config file instance, with a default implementation returning null. Ensure that this method is overridden where necessary.
Verify the usage and overriding of this method across the codebase.
Verification successful
getAppId()
Method Usage VerifiedThe
getAppId()
method in theConfigFile
interface is overridden in theAbstractConfigFile
class, which is the only class implementingConfigFile
. This confirms that the method is appropriately overridden where necessary. No further action is required.
- Implementations of
ConfigFile
:
AbstractConfigFile
(overridesgetAppId()
)Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage and overriding of `getAppId()` in classes implementing `ConfigFile`. # Test: Search for the method overriding. Expect: Overriding in all relevant classes. ast-grep --lang java --pattern $'class $_ implements ConfigFile { $$$ @Override String getAppId() { $$$ } $$$ }'Length of output: 127
Script:
#!/bin/bash # Find all classes implementing ConfigFile ast-grep --lang java --pattern 'class $_ implements ConfigFile { $$$ }' --json | jq -r '.[].matches[].text' > implementing_classes.txt # Check for getAppId method in these classes while IFS= read -r class; do echo "Checking class: $class" ast-grep --lang java --pattern "class $class { $$$ String getAppId() { $$$ } $$$ }" done < implementing_classes.txtLength of output: 132
Script:
#!/bin/bash # Search for any implementation of ConfigFile rg --no-heading --line-number 'implements ConfigFile' > implementations.txt # Search for any usage or overriding of getAppId() rg --no-heading --line-number 'getAppId' > getAppId_usages.txt # Output the results echo "Implementations of ConfigFile:" cat implementations.txt echo "Usages or overrides of getAppId():" cat getAppId_usages.txtLength of output: 10138
apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/NullProvider.java (1)
87-90
: Addition ofgetAccessKeySecret(String appId)
aligns with class purpose.The new method
getAccessKeySecret(String appId)
returnsnull
, which is consistent with theNullProvider
class's role as a default or placeholder implementation. This ensures that the interface contract is fulfilled without altering existing behavior.apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigFileChangeEvent.java (4)
26-26
: Introduction ofappId
field enhances context.The new
appId
field provides additional context for configuration file change events, aligning with the PR's objective to support multiple app IDs.
41-43
: Constructor updated to includeappId
.The constructor now accepts
appId
, ensuring that instances ofConfigFileChangeEvent
are initialized with complete context.
50-52
: Addition ofgetAppId()
method.The
getAppId()
method provides access to theappId
field, improving encapsulation and usability.
73-73
:toString()
method updated to includeappId
.Including
appId
in thetoString()
method enhances the string representation of the event, providing more detailed information.apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (3)
28-28
: Addition ofm_appId
field enhances context.The
m_appId
field provides additional context for configuration change events, aligning with the PR's objective to support multiple app IDs.
36-38
: Constructor updated to includeappId
.The constructor now includes
appId
, ensuring thatConfigChangeEvent
instances are initialized with complete context.
83-85
: Addition ofgetAppId()
method.The
getAppId()
method allows retrieval of theappId
, enhancing the class's utility.apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (1)
27-27
: LGTM! Verify the impact ofappId
integration.The introduction of the
appId
field and its integration into the constructor and the new getter method are well-executed. Ensure that existing code using theConfigChange
constructor is updated accordingly.Also applies to: 43-45, 81-83
Verification successful
Integration of
appId
Verified inConfigChange
ConstructorThe addition of the
appId
parameter to theConfigChange
constructor has been successfully integrated across the codebase. All instances ofConfigChange
creation have been updated to include theappId
parameter.
- Files Updated:
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of `appId` integration in the `ConfigChange` constructor across the codebase. # Test: Search for instantiations of `ConfigChange`. Expect: Updated constructor usage with `appId`. rg --type java 'new ConfigChange\('Length of output: 1593
apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (1)
45-55
: LGTM! Verify the usage of the new constructor.The addition of the new constructor with
appId
is well-implemented and maintains backward compatibility. Ensure that the new constructor is used appropriately in the codebase.Verification successful
Verified Usage of New Constructor
The new constructor for
PureApolloConfig
with parametersappId
,namespace
, andconfigRepository
is correctly used in the codebase. It appears inPureApolloConfigFactory.java
, and no other constructors are in use, ensuring consistency and correctness.
- Location of usage:
apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new `PureApolloConfig` constructor with `appId`. # Test: Search for instantiations of `PureApolloConfig`. Expect: Usage of both constructors. rg --type java 'new PureApolloConfig\('Length of output: 228
Script:
#!/bin/bash # Description: Search for all instantiations of `PureApolloConfig` to verify constructor usage. # Test: List all usages of `PureApolloConfig` constructors. rg --type java 'new PureApolloConfig\(' -A 3Length of output: 475
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (1)
110-114
: Verify the appId validation logic.Ensure that the validation logic for appId is correct and that it doesn't introduce breaking changes.
Verification successful
Validation logic for appId is correctly implemented.
The validation logic in the
create
method usesStringUtils.equals
to compare the provided appId with the expected one fromm_configUtil
. If they do not match, anIllegalArgumentException
is thrown. This is a standard and correct approach for ensuring appId consistency.
- The logic is correctly implemented and does not introduce breaking changes.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the appId validation logic in the `create` method. # Test: Search for the appId validation logic. Expect: Correct comparison and exception handling. rg --type java -A 5 $'if\\(!StringUtils.equals\\(appId,m_configUtil.getAppId\\(\\)\\)\\)'Length of output: 699
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (3)
61-63
: Constructor changes look good.The constructor now correctly initializes
m_appId
alongside other fields.
85-88
: MethodgetAppId
looks good.The method correctly returns the initialized
m_appId
.
Line range hint
102-125
:
MethodonRepositoryChange
changes look good.The method now correctly handles configuration changes with the appId parameter.
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java (3)
45-46
: Field initialization forconfigUtil
looks good.The field is correctly initialized using
ApolloInjector
.
56-77
: MethodregisterBeanDefinitions
changes look good.The method now correctly handles multiple appIds and resolves secrets, enhancing configuration flexibility.
106-112
: MethodresolveSecret
looks good.The method correctly resolves secrets and logs warnings for unsupported Spring versions.
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (8)
68-72
: LGTM! Test assertions updated for appId.The test assertions now correctly incorporate the
appId
, ensuring that the configuration retrieval logic is validated for the new parameter.
83-83
: LGTM! Test assertions updated for appId.The test assertions now correctly incorporate the
appId
, ensuring that the configuration factory logic is validated for the new parameter.
95-95
: LGTM! Test assertions updated for appId.The test assertions now correctly incorporate the
appId
, ensuring that the mock configuration factory logic is validated for the new parameter.
Line range hint
113-127
:
LGTM! Constructor and methods updated for appId.The
MockConfig
class now correctly incorporates theappId
parameter, enhancing the fidelity of mock configurations.
Line range hint
143-157
:
LGTM! Constructor updated for appId.The
MockConfigFile
class now correctly incorporates theappId
parameter, enhancing the fidelity of mock configuration files.
203-218
: LGTM! Methods updated for appId.The
MockConfigFactory
class methods now correctly incorporate theappId
parameter, enhancing the fidelity of mock configuration factories.
49-52
: Verify the use of reflection for setting private fields.Ensure that using reflection to access and modify private fields is necessary and correctly implemented, as it can lead to maintenance challenges.
Verification successful
Reflection usage is isolated and correctly implemented.
The use of reflection to access the
m_configUtil
field is limited to theConfigServiceTest.java
file, indicating it's specifically for testing purposes. This is a common practice for accessing private fields in tests and is correctly implemented in this context. No further issues found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the use of reflection for accessing `m_configUtil` in tests. # Test: Search for occurrences of reflection usage in test files. Expect: Consistent usage. rg --type java --pattern 'getDeclaredField\("m_configUtil"\)'Length of output: 475
Script:
#!/bin/bash # Description: Verify the use of reflection for accessing `m_configUtil` in tests. # Corrected Test: Search for occurrences of reflection usage in test files. Expect: Consistent usage. rg 'getDeclaredField\("m_configUtil"\)' --type javaLength of output: 203
169-172
: Verify thegetAppId
method returning null.Ensure that returning
null
from thegetAppId
method is intentional and does not affect the test logic.Verification successful
The
getAppId
method returning null is intentional and handled in tests.The test suite includes assertions that explicitly check for a
null
return value from thegetAppId()
method, indicating that this behavior is expected and managed within the test logic.
DefaultApplicationProviderTest
contains a test case that assertsnull
as the expected value.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `getAppId` method in tests. # Test: Search for calls to `getAppId` in test files. Expect: Handled cases for null return. rg --type java --pattern '\.getAppId\(\)'Length of output: 455
Script:
#!/bin/bash # Corrected: Search for calls to `getAppId` in test files to verify handling of null return. rg '\.getAppId\(\)' --type javaLength of output: 5923
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (10)
67-68
: LGTM! Method updated to use appId.The
create
method now correctly delegates to the overloaded version withappId
, ensuring consistent configuration creation.
Line range hint
70-91
:
LGTM! Method updated to handle appId.The
create
method now correctly incorporates theappId
parameter, ensuring configurations are created with the correct application context.
93-95
: LGTM! Method updated to use appId.The
createConfigFile
method now correctly delegates to the overloaded version withappId
, ensuring consistent configuration file creation.
98-99
: LGTM! Method updated to handle appId.The
createRepositoryConfig
method now correctly incorporates theappId
parameter, ensuring repository configurations are associated with the correct application context.
103-119
: LGTM! Method updated to handle appId.The
createConfigFile
method now correctly incorporates theappId
parameter, ensuring configuration files are created with the correct application context.
123-127
: LGTM! Method updated to handle appId.The
createConfigRepository
method now correctly incorporates theappId
parameter, ensuring configuration repositories are created with the correct application context.
137-144
: LGTM! Method updated to handle appId.The
createLocalConfigRepository
method now correctly incorporates theappId
parameter, ensuring local configuration repositories are created with the correct application context.
147-148
: LGTM! Method updated to handle appId.The
createRemoteConfigRepository
method now correctly incorporates theappId
parameter, ensuring remote configuration repositories are created with the correct application context.
Line range hint
152-157
:
LGTM! Method updated to handle appId.The
createPropertiesCompatibleFileConfigRepository
method now correctly incorporates theappId
parameter, ensuring properties-compatible file configuration repositories are created with the correct application context.
Line range hint
172-176
:
LGTM! Method updated to handle appId.The
trimNamespaceFormat
method now correctly incorporates theappId
parameter, ensuring namespace formatting is handled with the correct application context.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (3)
59-59
: LGTM! Data structure updated for appId.The
APP_NAMESPACE_NAMES
field now uses a more complex structure to handle multiple namespaces with specific appIds, enhancing flexibility.
73-79
: LGTM! Method updated to handle appId.The
addNamespaces
method now correctly incorporates theappId
parameter, ensuring namespaces are associated with the correct application context.
102-124
: LGTM! Method updated for appId-based configuration retrieval.The
initializePropertySources
method now correctly iterates over the new data structure, enhancing the granularity of configuration management.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (8)
68-68
: Transition to Table for structured configuration storage.The use of
HashBasedTable
forCONFIG_REGISTRY
allows for more structured storage of configurations associated with both app IDs and namespaces, enhancing flexibility.
94-101
: Update method signatures to include appId.The
prepareConfig
method now includesappId
, improving test configuration management by associating configurations with specific app IDs.
122-130
: Enhance YAML configuration handling with appId.The
prepareYamlConfigFile
method now acceptsappId
, ensuring YAML configurations are associated with the correct application context.
170-171
: Store configurations using appId and namespace.The
mockConfig
method now stores configurations in theCONFIG_REGISTRY
using bothappId
andnamespace
, aligning with the new table structure.
178-180
: Refactor config file mocking to include appId.The
mockConfigFile
method now usesappId
in its key, ensuring unique identification of config files across different applications.
204-204
: Clear configuration registry in teardown.The
doTearDown
method clearsCONFIG_REGISTRY
, ensuring no residual configurations affect subsequent tests.
222-228
: Refactor getConfig to use appId.The
getConfig
method inMockConfigManager
now requiresappId
, improving configuration retrieval by ensuring the correct application context is used.
Line range hint
236-242
: Refactor getConfigFile to use appId.The
getConfigFile
method inMockConfigManager
now includesappId
, aligning file retrieval with the new configuration structure.apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (6)
62-62
: Initialize someAppId for test clarity.The
someAppId
variable is now initialized to "someAppId", enhancing the clarity and context of the tests.
84-84
: Update method calls to include appId.The
createConfigRepository
method now acceptssomeAppId
, aligning with the updated configuration management logic.
99-99
: Refactor local config repository creation with appId.The
createLocalConfigRepository
method now includessomeAppId
, ensuring the test setup reflects the new configuration structure.
117-119
: Enhance properties file config repository creation with appId.The
createPropertiesCompatibleFileConfigRepository
method now requiressomeAppId
, aligning with the updated configuration logic.
136-138
: Update config file creation to include appId.The
createLocalConfigRepository
method calls now includesomeAppId
, ensuring the correct application context is used in tests.
191-204
: Refactor namespace name checks to include appId.The
checkNamespaceName
method now incorporatesappId
, ensuring comprehensive validation of namespace formatting.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (7)
66-67
: LGTM! Constructor changes are appropriate.The constructor correctly initializes
m_appId
and delegates to the other constructor.
70-74
: Constructor initialization is correct.The constructor properly initializes all fields and sets up the local cache directory and upstream repository.
133-134
: Delegation to overloaded method is correct.The method correctly delegates to the overloaded version with
m_appId
.
136-144
: Property update and change event handling are correct.The method correctly updates the file properties and fires the repository change event with
appId
.
Line range hint
204-237
:
File loading logic is correct.The method correctly handles loading properties from a local cache file using
appId
andnamespace
, with proper exception handling.
Line range hint
239-271
:
File persistence logic is correct.The method correctly handles persisting properties to a local cache file using
appId
andnamespace
, with proper exception handling.
297-300
: File path construction is correct.The method correctly constructs the file path using
appId
andnamespace
.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (4)
67-75
: Constructor initialization is correct.The constructor properly initializes
m_appId
usingConfigUtil.getAppId()
and sets up other fields.
Line range hint
84-92
:
Constructor initialization is correct.The constructor properly initializes all fields using the provided parameters.
243-244
: Delegation to overloaded method is correct.The method correctly delegates to the overloaded version with
m_appId
.
Line range hint
328-340
:
Resource loading logic is correct.The method correctly handles loading properties from a resource using
appId
andnamespace
, with proper exception handling.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (4)
Line range hint
96-114
:
Constructor initialization is correct.The constructor properly initializes
m_appId
and other fields, and sets up scheduled tasks.
157-160
: Config cache update and change event handling are correct.The method correctly updates the config cache and fires the repository change event with
m_appId
.
191-194
: Config loading logic is correct.The method correctly handles loading Apollo config using
m_appId
, with proper exception handling.
336-336
: Long polling refresh scheduling is correct.The method correctly schedules long polling refresh with
m_appId
.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (5)
Line range hint
115-141
:
LGTM!The inclusion of
sysAppId
as a parameter instartLongPolling
is a necessary change to support multiple app IDs and allows long polling to be scoped by application.
223-236
: LGTM!The addition of the
appId
parameter in thenotify
method is appropriate for associating notifications with the correct application.
247-260
: LGTM!The addition of the
appId
parameter in theupdateNotifications
method is appropriate for ensuring that notification updates are correctly associated with the respective application.
286-287
: LGTM!The inclusion of the
appId
parameter in theassembleNamespaces
method is necessary for assembling namespaces for a specific application ID.
106-112
: LGTM! But verify the function usage in the codebase.The addition of the
appId
parameter and the use ofTable
form_longPollNamespaces
andm_notifications
are appropriate for supporting multiple app IDs.However, ensure that all function calls to
submit
match the new signature.Verification successful
Function
submit
Usage VerifiedAll instances of the
submit
function in the codebase match the new signature withappId
,namespace
, andremoteConfigRepository
as arguments.
RemoteConfigLongPollServiceTest.java
: Multiple calls using the new signature.RemoteConfigRepository.java
: Single call using the new signature.No issues were found regarding the function usage.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `submit` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'submit'Length of output: 17711
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (3)
60-61
: LGTM!The introduction of the
someAppId
constant improves maintainability and readability by centralizing the application ID definition.
406-414
: LGTM!The addition of
throws Exception
to thebeforeClass
method enhances error handling during the setup phase of tests.
418-418
: LGTM!The addition of
throws NoSuchFieldException, IllegalAccessException
to theafterClass
method enhances error handling during the teardown phase of tests.apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (1)
513-515
: LGTM!The new method
getAccessKeySecret
appropriately extends the functionality ofConfigUtil
by enabling retrieval of access key secrets for specific app IDs.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (3)
Line range hint
22-32
: Imports look good.The addition of
MockInjector
andMultipleConfig
imports is appropriate for the new functionality.
651-675
: New test methodtestApolloMultipleConfig
looks good.The method effectively tests multiple configurations for different app IDs and namespaces.
1094-1131
: New configuration classTestApolloMultipleConfig
and beanTestApolloConfigBean5
look good.These additions support testing multiple app IDs and namespaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (9 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (14 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (29 hunks)
Additional comments not posted (28)
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (6)
94-101
: LGTM!The integration of
appId
into theprepareConfig
method is consistent with the PR's objectives and enhances configuration handling.
122-130
: LGTM!The addition of
appId
to theprepareYamlConfigFile
method is well-implemented and aligns with the PR's objectives.
170-171
: LGTM!The use of
appId
in themockConfig
method is appropriate and enhances the flexibility of configuration management.
178-180
: LGTM!The addition of
appId
to themockConfigFile
method and the use of a composite key enhance configuration management.
223-228
: LGTM!The integration of
appId
into thegetConfig
method inMockConfigManager
is well-implemented and aligns with the PR's objectives.
Line range hint
237-242
:
LGTM!The addition of
appId
to thegetConfigFile
method inMockConfigManager
enhances the retrieval process for configuration files.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java (1)
109-113
: LGTM!The integration of
appId
in theprocessApolloConfig
method enhances configuration retrieval and aligns with the PR's objectives.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (7)
155-155
: LGTM!The test case
testLoadConfig
correctly incorporatessomeAppId
in theRemoteConfigRepository
instantiation, aligning with the updated configuration handling.
181-181
: LGTM!The test case
testLoadConfigWithOrderedProperties
correctly usessomeAppId
in theRemoteConfigRepository
instantiation, ensuring proper testing of ordered properties.
218-218
: LGTM!The test case
testLoadConfigWithAccessKeySecret
correctly incorporatessomeAppId
in theRemoteConfigRepository
instantiation, aligning with the updated configuration handling.
231-231
: LGTM!The test case
testGetRemoteConfigWithServerError
correctly usessomeAppId
in theRemoteConfigRepository
instantiation, ensuring proper error handling testing.
244-244
: LGTM!The test case
testGetRemoteConfigWithNotFount
correctly incorporatessomeAppId
in theRemoteConfigRepository
instantiation, aligning with the updated configuration handling.
Line range hint
261-272
:
LGTM!The test case
testRepositoryChangeListener
correctly verifiesonRepositoryChange
withsomeAppId
, ensuring proper testing of repository change notifications.
Line range hint
295-321
:
LGTM!The test case
testLongPollingRefresh
correctly verifiesonRepositoryChange
withsomeAppId
, ensuring proper testing of long polling refresh.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (5)
194-194
: LGTM!The addition of the
appId
parameter to thesubmit
method call is consistent with the changes in other test cases.
256-256
: LGTM!The addition of the
appId
parameter to thesubmit
method call is consistent with the changes in other test cases.
327-330
: LGTM!The addition of the
appId
parameter to thesubmit
method calls for multiple namespaces is consistent with the changes in other test cases.
398-399
: LGTM!The addition of the
appId
parameter to thesubmit
method calls for multiple namespaces with multiple notifications is consistent with the changes in other test cases.
143-143
: LGTM! Verifysubmit
method usage withappId
.The addition of the
appId
parameter to thesubmit
method call is consistent with the PR objectives.Ensure that all
submit
method calls in the codebase correctly include theappId
parameter.Verification successful
Let's correct the regex pattern error and re-run the script to verify the usage of the
submit
method with theappId
parameter.
Verification Successful:
submit
Method Usage ConsistentThe
submit
method calls across the codebase correctly include theappId
parameter, aligning with the intended changes. No issues found.
RemoteConfigLongPollService.java
: Thesubmit
method is defined withappId
.RemoteConfigLongPollServiceTest.java
: Test cases consistently useappId
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all `submit` method calls include the `appId` parameter. # Test: Search for `submit` method usage. Expect: Occurrences with the `appId` parameter. rg --type java -A 2 $'submit('Length of output: 96
Script:
#!/bin/bash # Description: Verify all `submit` method calls include the `appId` parameter. # Test: Search for `submit` method usage. Expect: Occurrences with the `appId` parameter. rg --type java -A 2 'submit\('Length of output: 6210
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (9)
116-119
: LGTM!The addition of
someAppId
to themockConfig
andprepareYamlConfigFile
method calls is consistent with the PR objectives.
135-135
: LGTM!The addition of
someAppId
to themockConfig
method call is consistent with the changes in other test cases.
145-147
: LGTM!The addition of
someAppId
to themockConfig
andprepareYamlConfigFile
method calls is consistent with the changes in other test cases.
161-164
: LGTM!The addition of
someAppId
to themockConfig
method call is consistent with the changes in other test cases.
Line range hint
176-185
:
LGTM!The addition of
someAppId
to themockConfig
method calls is consistent with the changes in other test cases.
197-198
: LGTM!The addition of
someAppId
to themockConfig
method calls is consistent with the changes in other test cases.
212-213
: LGTM!The addition of
someAppId
to themockConfig
method calls is consistent with the changes in other test cases.
266-266
: LGTM!The addition of
someAppId
to themockConfig
method call is consistent with the changes in other test cases.
660-684
: LGTM!The new test method
testApolloMultipleConfig
effectively tests multiple configurations for different app IDs and namespaces, aligning with the PR objectives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (15 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java (2 hunks)
Files skipped from review as they are similar to previous changes (3)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
- apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java
Additional comments not posted (8)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (8)
72-73
: Good use ofTable
for structured data management.The transition to using
Table
form_longPollNamespaces
andm_notifications
is a suitable choice for managing multiple app IDs and namespaces. This enhances the capability to associate multiple values with a single key in a structured manner.
95-96
: Thread-safe initialization ofTable
data structures.The use of
Tables.synchronizedTable
form_longPollNamespaces
andm_notifications
ensures thread safety, which is essential for the concurrent nature of this service.
106-112
: Correct handling of appId insubmit
method.The
submit
method appropriately handles theappId
parameter, updating theTable
data structures and initiating long polling if necessary.
Line range hint
115-141
:
Efficient management of long polling state with appId.The
startLongPolling
method effectively uses thesysAppId
to manage the long polling state, ensuring that polling is only initiated once per appId.
Line range hint
172-211
:
Proper integration of appId in long polling logic.The
doLongPollingRefresh
method correctly incorporates theappId
into its URL assembly and notification handling logic, ensuring operations are scoped to the correct application.
223-236
: Correct use of appId in notification logic.The
notify
method effectively uses theappId
to retrieve the appropriateRemoteConfigRepository
instances and notify them of changes.
247-260
: Appropriate update of notifications with appId.The
updateNotifications
method correctly updates the notification IDs for the givenappId
and namespace, ensuring accurate tracking of changes.
286-287
: Correct assembly of namespaces with appId.The
assembleNamespaces
method correctly assembles the namespaces for the specifiedappId
, ensuring accurate representation of the data.
I have changed the Email for submitting code to [email protected], and changed the name to TerryLam2010. Have not submitted open source request merge before,help me please.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your hard work on this significant change. Here are a few comments for your review.
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
Outdated
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
Outdated
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range, codebase verification and nitpick comments (3)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (2)
Update method calls to match the new signature
The
onRepositoryChange
method is being called with both the new and old signatures across the codebase. Ensure all calls are updated to match the new signature:onRepositoryChange(String appId, String namespace, Properties newProperties)
, unless there is a specific reason to maintain both versions.
- Files with old signature usage:
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderAutoUpdateTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderAutoUpdateTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
Analysis chain
Line range hint
116-136
: LGTM! But verify the method usage in the codebase.The method is correctly implemented. However, ensure that all method calls to
onRepositoryChange
match the new signature.The code changes are approved.
Run the following script to verify the method usage:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `onRepositoryChange` match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'onRepositoryChange'Length of output: 63127
113-114
: Inconsistent method signature usage detectedThe
onRepositoryChange
method is being called with both the new and old signatures across the codebase. Ensure that all calls to this method are updated to use the new signature, which includes theappId
parameter, to prevent potential runtime errors or unexpected behavior.
- Files with old signature usage:
JsonConfigFileTest.java
YamlConfigFileTest.java
XmlConfigFileTest.java
DefaultConfigTest.java
PropertiesConfigFileTest.java
JavaConfigPlaceholderAutoUpdateTest.java
Please update these instances to use the new method signature.
Analysis chain
LGTM! But verify the method usage in the codebase.
The method is correctly implemented. However, ensure that all method calls to
onRepositoryChange
match the new signature.The code changes are approved.
Run the following script to verify the method usage:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `onRepositoryChange` match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'onRepositoryChange'Length of output: 63127
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (1)
Line range hint
143-172
: Fix thegetAppId
method.The
getAppId
method should return the actualappId
instead ofnull
.Apply this diff to fix the
getAppId
method:- return null; + return m_appId;
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (17)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (8 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (5 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (15 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (29 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (6 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java (1 hunks)
Additional comments not posted (58)
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (1)
52-57
: LGTM!The addition of the
appId
parameter enhances the flexibility of the annotation. The parameter is well-documented with a brief description and version information.The code changes are approved.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (2)
33-37
: LGTM!The constructor correctly initializes
ConfigUtil
andConfigRegistry
.The code changes are approved.
42-46
: LGTM!The changes improve the flexibility of factory retrieval by making it context-aware based on
appId
. The logic withingetFactory(String appId, String namespace)
is well-structured.The code changes are approved.
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1)
38-46
: LGTM!The addition of the
getAppId
method enhances the interface by providing a standardized way to retrieve theappId
. The default implementation ensures backward compatibility.The code changes are approved.
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1)
72-78
: LGTM!The addition of the
multipleConfigs
method enhances the configurability of the interface by allowing for more flexible application settings related to multiple configurations. The default value ensures backward compatibility.The code changes are approved.
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (3)
100-127
: LGTM! But verify the method usage in the codebase.The method is correctly implemented. However, ensure that all method calls to
setConfig
match the new signature.The code changes are approved.
Run the following script to verify the method usage:
Verification successful
Method Signature Change Verified
The
setConfig
method calls in the codebase match the new signature. The relevant test file confirms the correct usage. No discrepancies found.
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
: Correct usage ofsetConfig
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `setConfig` match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'setConfig'Length of output: 10715
82-84
: LGTM! But verify the method usage in the codebase.The method is correctly implemented. However, ensure that all method calls to
getConfig
match the new signature.The code changes are approved.
Run the following script to verify the method usage:
111-116
: LGTM! But verify the method usage in the codebase.The method is correctly implemented. However, ensure that all method calls to
create
match the new signature.The code changes are approved.
Run the following script to verify the method usage:
Verification successful
Method Implementation and Usage Verified
The
create(String appId, String namespace)
method is correctly implemented inConfigService.java
and used with the expected signature in the codebase.
- Method Definition: Found in
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
- Relevant Usage: Found in
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all method calls to `create` match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'create'Length of output: 176808
Script:
#!/bin/bash # Search for the specific `create(String appId, String namespace)` method implementation in the `ConfigService` class. ast-grep --lang java --pattern $'class ConfigService { $$$ public Config create(String appId, String namespace) { $$$ } $$$ }' # Search for the usage of `create(String appId, String namespace)` method across the codebase. ast-grep --lang java --pattern $'$_.$create($_, $_)' --pattern-insensitiveLength of output: 420
Script:
#!/bin/bash # Corrected search for the specific `create(String appId, String namespace)` method implementation in the `ConfigService` class. ast-grep --lang java --pattern $'class ConfigService { $$$ public Config create(String appId, String namespace) { $$$ } $$$ }' # Corrected search for the usage of `create(String appId, String namespace)` method across the codebase. ast-grep --lang java --pattern $'$_.$create($_, $_)'Length of output: 195
Script:
#!/bin/bash # Search for the `create(String appId, String namespace)` method definition in the `ConfigService` class. rg --type java 'public Config create\(String appId, String namespace\)' # Search for the usage of `create(String appId, String namespace)` method across the codebase. rg --type java '\.create\([^\)]*, [^\)]*\)'Length of output: 2870
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (2)
57-58
: LGTM! But verify the constructor usage in the codebase.The constructor is correctly implemented. However, ensure that all constructor calls to
SimpleConfig
match the new signature.The code changes are approved.
Run the following script to verify the constructor usage:
Verification successful
Constructor usage is consistent with the new signature.
The codebase correctly uses the new constructor signature for
SimpleConfig
, ensuring that all instances are created with the required parameters:appId
,namespace
, andconfigRepository
. No instances of the old constructor signature were found.
- Ensure that any future changes maintain this consistency.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `SimpleConfig` match the new signature. # Test: Search for the constructor usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'SimpleConfig'Length of output: 46705
67-70
: LGTM! But verify the constructor usage in the codebase.The constructor is correctly implemented. However, ensure that all constructor calls to
SimpleConfig
match the new signature.The code changes are approved.
Run the following script to verify the constructor usage:
Verification successful
Constructor Usage Verified: All instances align with the new signature.
The
SimpleConfig
constructor is correctly used across the codebase, particularly through theprepareConfig
method in tests, ensuring alignment with the new signature.
AbstractSpringIntegrationTest.java
:prepareConfig
method correctly implements the new constructor signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `SimpleConfig` match the new signature. # Test: Search for the constructor usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'SimpleConfig'Length of output: 46705
Script:
#!/bin/bash # Description: Locate the implementation of the `prepareConfig` method to verify its correctness. # Search for the implementation of the `prepareConfig` method in Java files. rg --type java -A 5 'prepareConfig'Length of output: 38742
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (4)
58-58
: LGTM!The method is correctly implemented.
The code changes are approved.
86-87
: LGTM!The method is correctly implemented.
The code changes are approved.
116-116
: LGTM!The method is correctly implemented.
The code changes are approved.
161-161
: LGTM!The method is correctly implemented.
The code changes are approved.
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (6)
45-53
: LGTM!The
setUp
method correctly initializessomeAppId
and sets up a mockConfigUtil
.The code changes are approved.
68-72
: LGTM!The
testHackConfig
method correctly tests the configuration with the newappId
parameter.The code changes are approved.
83-83
: LGTM!The
testHackConfigFactory
method correctly tests the configuration factory with the newappId
parameter.The code changes are approved.
95-95
: LGTM!The
testMockConfigFactory
method correctly tests the mock configuration factory with the newappId
parameter.The code changes are approved.
104-104
: LGTM!The
testMockConfigFactoryForConfigFile
method correctly tests the mock configuration factory for config files with the newappId
parameter.The code changes are approved.
Line range hint
113-127
: LGTM!The
MockConfig
class correctly integrates theappId
parameter and updates thegetProperty
method to reflect this change.The code changes are approved.
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (5)
59-59
: LGTM!The static field
APP_NAMESPACE_NAMES
correctly represents the namespaces associated with specific application IDs.The code changes are approved.
69-76
: LGTM!The
addNamespaces
method correctly updates the namespace management to accommodate multiple application IDs.The code changes are approved.
99-121
: LGTM!The
initializePropertySources
method correctly updates the property source initialization to accommodate multiple application IDs.The code changes are approved.
173-173
: LGTM!The
reset
method correctly updates the reset logic to accommodate the new data structure.The code changes are approved.
78-78
: LGTM!The
postProcessBeanFactory
method correctly updates the bean factory post-processing to accommodate the new data structure and configuration logic.The code changes are approved.
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (7)
68-68
: LGTM!The static field
CONFIG_REGISTRY
correctly represents the configurations associated with specific application IDs and namespaces.The code changes are approved.
94-101
: LGTM!The
prepareConfig
method correctly updates the configuration preparation to accommodate the newappId
parameter.The code changes are approved.
122-130
: LGTM!The
prepareYamlConfigFile
method correctly updates the YAML configuration file preparation to accommodate the newappId
parameter.The code changes are approved.
170-171
: LGTM!The
mockConfig
method correctly updates the configuration mocking to accommodate the newappId
parameter.The code changes are approved.
178-180
: LGTM!The
mockConfigFile
method correctly updates the configuration file mocking to accommodate the newappId
parameter.The code changes are approved.
Line range hint
182-201
: LGTM!The
doSetUp
method correctly updates the setup logic to accommodate the newappId
parameter and configuration logic.The code changes are approved.
219-238
: LGTM!The
MockConfigManager
class correctly updates the configuration management to accommodate the newappId
parameter.The code changes are approved.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (6)
70-71
: LGTM!The constructor correctly calls another constructor with the
appId
parameter.The code changes are approved.
80-85
: LGTM!The constructor correctly initializes the class variables with the
appId
parameter.The code changes are approved.
239-240
: LGTM!The method correctly calls the overloaded method with the
appId
parameter.The code changes are approved.
Line range hint
243-260
: LGTM!The method correctly handles the repository change with the
appId
parameter.The code changes are approved.
273-273
: LGTM!The method correctly calculates and updates the configuration changes with the
appId
parameter.The code changes are approved.
Line range hint
324-336
: LGTM!The method correctly loads properties from the resource file with the
appId
andnamespace
.The code changes are approved.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (6)
93-96
: LGTM!The constructor correctly initializes the class variables with
ConcurrentHashMap
andTable
.The code changes are approved.
106-112
: LGTM!The method correctly handles the submission with the
appId
parameter.The code changes are approved.
Line range hint
115-145
: LGTM!The method correctly handles the long polling start with the
sysAppId
parameter.The code changes are approved.
Line range hint
176-215
: LGTM!The method correctly handles the long polling refresh with the
appId
parameter.The code changes are approved.
227-240
: LGTM!The method correctly handles the notifications with the
appId
parameter.The code changes are approved.
251-264
: LGTM!The method correctly handles the notification updates with the
appId
parameter.The code changes are approved.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (6)
Line range hint
106-135
: LGTM!The method correctly initializes the test setup with the
appId
parameter.The code changes are approved.
155-155
: LGTM!The test method correctly tests the configuration loading with the
appId
parameter.The code changes are approved.
181-181
: LGTM!The test method correctly tests the configuration loading with ordered properties and the
appId
parameter.The code changes are approved.
218-218
: LGTM!The test method correctly tests the configuration loading with access key secret and the
appId
parameter.The code changes are approved.
231-231
: LGTM!The test method correctly tests the exception handling with the
appId
parameter.The code changes are approved.
Line range hint
261-272
: LGTM!The test method correctly tests the repository change listener with the
appId
parameter.The code changes are approved.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (7)
87-91
: LGTM!The
setUp
method correctly initializes the test environment withsomeAppId
and sets the system property forAPP_ID
.The code changes are approved.
149-149
: LGTM!The test correctly includes
someAppId
in thesubmit
method call and verifies the URL contains the correctappId
.The code changes are approved.
200-200
: LGTM!The test correctly includes
someAppId
in thesubmit
method call and verifies the correct processing of notifications.The code changes are approved.
262-263
: LGTM!The test correctly includes
someAppId
in thesubmit
method call and verifies the request headers contain the necessary authentication information.The code changes are approved.
333-336
: LGTM!The test correctly includes
someAppId
in thesubmit
method calls for multiple namespaces and verifies the correct processing of notifications for each namespace.The code changes are approved.
404-405
: LGTM!The test correctly includes
someAppId
in thesubmit
method calls for multiple namespaces with multiple notifications and verifies the correct processing of notifications for each namespace.The code changes are approved.
465-465
: LGTM!The test correctly includes
someAppId
in thesubmit
method call and verifies the correct processing and updating of notifications.The code changes are approved.
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (1)
660-684
: LGTM!The test correctly handles multiple configurations with multiple app IDs and verifies the correct configurations are returned for each app ID and namespace.
The code changes are approved.
apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Show resolved
Hide resolved
emm...You may first backup the local repo and try the following: 1. git checkout main
2. git checkout -b 20240703-apollo-multiple-appid-new
3. git merge --squash 20240703-apollo-multiple-appid
4. git commit -m "some commit message"
5. git push origin 20240703-apollo-multiple-appid-new:20240703-apollo-multiple-appid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks significantly better now. Please see some comments below:
...ig-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java
Outdated
Show resolved
Hide resolved
...ig-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java
Outdated
Show resolved
Hide resolved
...ig-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java
Outdated
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 13
Outside diff range, codebase verification and nitpick comments (10)
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (4)
21-30
: Enhance Annotation DocumentationConsider adding more details about how
MultipleConfig
interacts with@EnableApolloConfig
to provide clearer guidance for developers.
32-36
: EnhanceappId
Method DocumentationThe documentation for the
appId
method should include more details about what constitutes an "appId" and how it should be formatted or used.
38-42
: Enhancenamespaces
Method DocumentationThe documentation for the
namespaces
method should include more details about the purpose of namespaces and examples of typical values.
44-50
: Enhancesecret
Method DocumentationThe documentation for the
secret
method should include more details about the significance of the secret, its typical use cases, and implications of not configuring it.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (1)
47-53
: Approved newregister
method with a suggestion.The method correctly handles potential conflicts by logging a warning. Consider adding more detailed logging or metrics to track how often conflicts occur, which could be useful for monitoring and debugging.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (1)
Line range hint
48-73
: Implementation ofgetFactory(String appId, String namespace)
:The method's implementation is robust, covering various scenarios:
- It first checks for a "hacked" factory specific to the app ID and namespace.
- It checks the cache implemented using
HashBasedTable
.- It attempts to retrieve a declared config factory.
- It falls back to a default config factory if none are found.
The method ensures that the factory is never null by the end, which is crucial for avoiding null pointer exceptions. However, consider adding explicit logging or an exception throw if the factory is still null after all checks, to improve error handling and debuggability.
Consider enhancing error handling by adding logging or throwing an exception if no factory is found:
if (factory == null) { logger.error("No ConfigFactory found for appId: {}, namespace: {}", appId, namespace); throw new IllegalStateException("No ConfigFactory found for appId: " + appId + ", namespace: " + namespace); }apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (1)
Line range hint
119-139
: Approved: Handling ofappId
inonRepositoryChange
.The method's logic to handle configuration changes based on the specified
appId
is correctly implemented. However, consider adding more detailed logging for debugging purposes, especially to trace how differentappId
s affect the configuration changes.apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (1)
68-68
: Inconsistent use ofappId
across test methods.The
testHackConfig
method uses thesomeAppId
parameter, but other methods liketestHackConfigFactory
,testMockConfigFactory
, andtestMockConfigFactoryForConfigFile
do not. This inconsistency may lead to incomplete test coverage if the goal is to validate behavior across different app IDs. Consider reviewing these methods to ensure they align with the intended test scenarios.
testHackConfig
usessomeAppId
.testHackConfigFactory
,testMockConfigFactory
, andtestMockConfigFactoryForConfigFile
do not usesomeAppId
.Analysis chain
Ensure consistency in the use of
appId
across test methods.The addition of
appId
in the test methodstestHackConfig
,testHackConfigFactory
, andtestMockConfigFactory
is consistent with the PR's objective to handle multiple app IDs. However, ensure that all related test methods and classes are updated accordingly to maintain consistency across the entire test suite.Also applies to: 72-72, 83-83, 95-95
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all test methods in ConfigServiceTest.java use the `appId` parameter consistently. # Test: Search for test methods that might not be using the `appId` parameter. rg --type java -A 5 $'public void test' apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.javaLength of output: 1217
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (2)
Line range hint
128-154
: Ensure robust error handling instartLongPolling
.The method
startLongPolling
has been adapted to handle app-specific long polling. The use ofputIfAbsent
form_longPollStarted
is appropriate for concurrency control. However, the error handling could be improved by ensuring that any exceptions caught are properly logged and handled to prevent the long polling service from terminating unexpectedly.Consider adding more detailed logging and a more robust exception handling strategy:
catch (Throwable ex) { m_longPollStarted.remove(sysAppId); ApolloConfigException exception = new ApolloConfigException("Schedule long polling refresh failed", ex); + logger.error("Failed to schedule long polling for appId: {}", sysAppId, ex); Tracer.logError(exception); logger.warn(ExceptionUtil.getDetailMessage(exception)); }
This enhancement ensures that all exceptions are adequately logged, providing better visibility into issues that occur during the scheduling of long polling.
Line range hint
185-206
: Optimize the long polling refresh logic.The
doLongPollingRefresh
method handles the core functionality of long polling. The method is well-structured to handle different scenarios and responses. However, the handling of the304
status code could be improved to ensure that the service descriptor (lastServiceDto
) is reset more reliably.Consider refining the condition for resetting
lastServiceDto
:if (response.getStatusCode() == 304 && ThreadLocalRandom.current().nextBoolean()) { - lastServiceDto = null; + if (shouldResetServiceDescriptor()) { + lastServiceDto = null; + } }Introducing a method
shouldResetServiceDescriptor
allows for more controlled and testable conditions for when the service descriptor should be reset, improving the reliability of the long polling mechanism.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (22)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (7 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (8 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PlainTextConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java (3 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java (3 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (2 hunks)
Additional comments not posted (69)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PlainTextConfigFile.java (1)
27-28
: Constructor Modification: Addition ofappId
ParameterThe constructor now includes an
appId
parameter, which is a significant change aligning with the project's goal to support multiple app IDs. This change is correctly implemented as theappId
is passed to the superclass constructor, ensuring that theAbstractConfigFile
can utilize this new parameter.However, it's crucial to verify that all existing usages of this constructor in the codebase have been updated to include the new
appId
parameter to prevent runtime errors.Verification successful
Constructor Change Verified:
appId
Parameter PropagationThe addition of the
appId
parameter to thePlainTextConfigFile
constructor has been correctly propagated to all its subclasses (XmlConfigFile
,TxtConfigFile
,JsonConfigFile
,YamlConfigFile
). Each subclass constructor includes theappId
parameter, ensuring consistency and preventing potential runtime errors.
XmlConfigFile
:public XmlConfigFile(String appId, String namespace, ...)
TxtConfigFile
:public TxtConfigFile(String appId, String namespace, ConfigRepository configRepository)
JsonConfigFile
:public JsonConfigFile(String appId, String namespace, ...)
YamlConfigFile
:public YamlConfigFile(String appId, String namespace, ConfigRepository configRepository)
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `PlainTextConfigFile` include the new `appId` parameter. # Test: Search for the constructor usage. Expect: Only occurrences with three parameters. rg --type java -A 5 $'new PlainTextConfigFile'Length of output: 47
Script:
#!/bin/bash # Description: Search for all usages of the `PlainTextConfigFile` class to verify constructor usage. # Test: Search for any references to `PlainTextConfigFile` in the codebase. rg --type java 'PlainTextConfigFile'Length of output: 995
Script:
#!/bin/bash # Description: Search for constructors in subclasses of `PlainTextConfigFile` to verify if `appId` is passed correctly. # Test: Search for constructors in subclasses of `PlainTextConfigFile`. rg --type java -A 5 $'class XmlConfigFile {\n public XmlConfigFile' rg --type java -A 5 $'class TxtConfigFile {\n public TxtConfigFile' rg --type java -A 5 $'class JsonConfigFile {\n public JsonConfigFile' rg --type java -A 5 $'class YamlConfigFile {\n public YamlConfigFile'Length of output: 1443
Script:
#!/bin/bash # Description: Search for constructors in subclasses of `PlainTextConfigFile` to verify if `appId` is passed correctly. # Test: Search for constructors in subclasses of `PlainTextConfigFile`. rg --type java 'public XmlConfigFile' rg --type java 'public TxtConfigFile' rg --type java 'public JsonConfigFile' rg --type java 'public YamlConfigFile'Length of output: 795
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (1)
1-17
: Header and Package Declaration ApprovedThe file header, including copyright and licensing information, and the package declaration are correctly formatted.
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (2)
52-58
: Approved: Addition ofappId
attribute toApolloConfig
.The addition of the
appId
attribute aligns with the PR objectives and enhances configuration flexibility. The documentation is clear and specifies the version introduction. This change is consistent with the suggestions from previous reviews.
52-58
: Verify the integration of the newappId
attribute across the codebase.Ensure that the new
appId
attribute is correctly integrated and utilized in relevant parts of the codebase.Run the following script to verify the usage of the
appId
attribute:Verification successful
The
appId
attribute is correctly integrated across the codebase.The
appId
attribute in theApolloConfig
annotation is utilized in theApolloAnnotationProcessor
class, which processes the annotation, indicating its integration into the application logic. Additionally, its presence in various DTOs and test files confirms its usage and testing. No further action is required.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `appId` attribute in the ApolloConfig annotation across the codebase. # Test: Search for the usage of the `appId` attribute. Expect: Proper integration and usage. rg --type java -A 5 $'@ApolloConfig\\(.*appId.*\\)'Length of output: 851
Script:
#!/bin/bash # Description: Verify the usage of the `appId` attribute in the main codebase. # Test: Search for the usage of the `appId` attribute in the main codebase. Expect: Proper integration and usage. rg --type java -A 5 'appId\s*='Length of output: 38709
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (2)
34-40
: Review of the newgetConfig
method with appId support.The addition of the
getConfig(String appId, String namespace)
method is well-documented and aligns with the PR's objective to support multiple app IDs. The method signature and JavaDoc are clear and concise.
- Correctness: The method signature correctly takes
appId
andnamespace
as parameters, which is consistent with the PR's description.- Documentation: The JavaDoc is appropriately detailed, providing clear information on what the method does and its parameters.
50-57
: Review of the newgetConfigFile
method with appId support.The addition of the
getConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
method extends the functionality to fetch configuration files for specific app IDs and namespaces. This method is crucial for environments where multiple applications might share configurations but need distinct setups.
- Correctness: The method signature is correct and includes all necessary parameters (
appId
,namespace
,configFileFormat
).- Documentation: The JavaDoc is well-written, clearly explaining the purpose of the method and the parameters it accepts.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (4)
19-23
: Approved import changes.The new imports are necessary for handling the new
appId
functionality and concurrency control withTable
.
32-37
: Approved class setup and instance variables.The use of
ConfigUtil
to fetch theappId
and a synchronized table for storingConfigFactory
instances ensures thread safety and supports the new functionality.
44-45
: Approved method delegation for backward compatibility.The
register
method now correctly delegates to the new method acceptingappId
, ensuring backward compatibility.
58-63
: Approved method changes forgetFactory
.The changes to
getFactory
methods are consistent with the new functionality and maintain backward compatibility by using the defaultappId
.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (3)
19-20
: Review of Imports:The addition of
HashBasedTable
andTable
from Guava and the import ofConfigUtil
are appropriate given the changes to support multiple app IDs. Ensure thatMaps
is still used elsewhere in the project, or consider removing it if it's no longer needed.Also applies to: 24-24
33-35
: Initialization of New Members:The introduction of
m_factories
as aHashBasedTable
andm_configUtil
is well-aligned with the new requirements for handling multiple app IDs. The instantiation ofm_configUtil
in the constructor ensures that the application ID can be dynamically retrieved, which is crucial for the new logic.Also applies to: 39-39
44-45
: Refactor ofgetFactory(String namespace)
:The method now delegates to the new
getFactory(String appId, String namespace)
by fetching the app ID usingm_configUtil
. This is a clean and efficient way to integrate the new functionality without duplicating code.apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (3)
28-28
: Field addition approved:m_appId
.The addition of the
m_appId
field is correctly implemented as a private final String, ensuring immutability and thread safety.
36-38
: Constructor modification approved.The updated constructor now correctly includes the
appId
parameter and initializes them_appId
field along withm_namespace
andm_changes
. This change supports the new functionality of handling multiple app IDs effectively.
78-84
: New method addition approved:getAppId()
.The addition of the
getAppId()
method is correctly implemented to provide external access to them_appId
field, adhering to Java's encapsulation principles.apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (3)
27-27
: Field addition approved.The addition of the
appId
field is crucial for supporting multiple app IDs and is correctly declared asprivate final
for immutability.
43-45
: Constructor modification approved.The modification to include
appId
as the first parameter in the constructor is logical and necessary for initializing the new field correctly.
80-82
: Getter method addition approved.The addition of the
getAppId
method is essential for providing external access to theappId
field, enhancing the class's functionality.apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (1)
42-52
: Well-implemented new constructor withappId
.The addition of the
appId
parameter in the constructor enhances the configuration management capabilities as intended. The constructor is well-documented and correctly initializes the superclass with the new parameter.Please ensure that all integrations and usages of this new constructor are updated across the codebase to reflect the new parameter. This can be verified by searching for instances of
PureApolloConfig
instantiation and checking if they now include theappId
parameter.Verification successful
New constructor usage verified in
PureApolloConfigFactory
.The instantiation of
PureApolloConfig
inPureApolloConfigFactory.java
correctly uses the new constructor with theappId
parameter. This confirms that the integration of the new constructor is consistent with its intended usage.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instances of `PureApolloConfig` instantiation include the new `appId` parameter. # Test: Search for the constructor usage. Expect: Only occurrences with the new signature. rg --type java -A 5 $'new PureApolloConfig'Length of output: 473
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (5)
27-31
: Addition of new imports for enhanced configuration management.The addition of
ConfigUtil
andTable
from Guava supports the new functionality for handling multiple app IDs. This aligns with the PR's objective to enhance configuration capabilities.
39-46
: Initialization of new data structures for configuration management.The use of
Table
form_configs
andm_configFiles
is a significant change that allows storing configurations with a compound key of appId and namespace. This is a robust approach to handle configurations in a multi-application environment.
52-52
: Initialization ofConfigUtil
in the constructor.This change is crucial as
ConfigUtil
is used to fetch theappId
dynamically in the overridden methods. It ensures that theappId
can be retrieved consistently across different parts of the application.
57-58
: Delegation ofgetConfig
to the new method withappId
.This change maintains backward compatibility by delegating to the new
getConfig
method that includesappId
. It's a good practice to ensure that existing code relying on the old method signature continues to work without modification.
82-83
: Delegation ofgetConfigFile
to the new method withappId
.Similar to
getConfig
, this change ensures backward compatibility by delegating to the newgetConfigFile
method that includesappId
. This is a good practice for maintaining existing functionality while extending new features.apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (3)
82-84
: New method for fetching configuration by appId and namespace.The implementation of
getConfig(String appId, String namespace)
correctly extends the functionality to handle multiple app IDs, aligning with the PR's objectives.
110-116
: Validation of appId in configuration creation.The addition of appId validation in
create(String appId, String namespace)
ensures that configurations are correctly associated with their respective applications. This is a critical enhancement for maintaining configuration integrity.
22-22
: Import of StringUtils.The addition of
StringUtils
is necessary for the appId comparison logic in the new methods. This is a justified and appropriate use of the library.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (4)
42-42
: Approved: Introduction ofm_appId
and related changes.The addition of
m_appId
and its integration into the constructors and methods aligns with the PR's objective to handle multiple app IDs effectively.Also applies to: 67-71
57-58
: Approved: Constructor delegation for backward compatibility.The updated constructor that delegates to the new constructor with
appId
asnull
ensures backward compatibility while supporting the new functionality.
116-117
: Approved: Overloading ofonRepositoryChange
to handleappId
.The method now correctly delegates handling to the version that accepts an
appId
, aligning with the new functionality requirements.
68-70
: Approved: Dynamic fetching ofappId
usingConfigUtil
.The approach to dynamically fetch the
appId
if not provided ensures robustness in handling configurations. Ensure thatConfigUtil
is always correctly initialized and available to avoid potential null pointer exceptions.apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java (8)
102-104
: Approved: New method signature forConfig create
.The addition of the
appId
parameter aligns with the PR's objectives to support multiple app IDs. The implementation is consistent with the interface's requirements.
112-114
: Approved: New method signature forConfigFile createConfigFile
.The addition of the
appId
parameter enhances the method's capability to handle configurations specific to an application ID, which is crucial for multi-application environments.
124-126
: Approved: New method signature forvoid register
.The updated method signature allows for more granular control over configuration factories based on both application ID and namespace, supporting the PR's goal of enhanced configuration management.
137-142
: Approved: New method signature forConfigFactory getFactory
.This method now supports fetching factories based on both
appId
andnamespace
, enhancing the flexibility and specificity of configuration retrieval.
152-154
: Approved: Consistent implementation ofConfig create
across different factories.The method's implementation is aligned with the interface's new requirements, supporting configurations specific to both an application ID and a namespace.
162-164
: Approved: Consistent implementation ofConfigFile createConfigFile
across different factories.This method now allows for the creation of configuration files that are specific to both an application ID and a namespace, enhancing the system's configurability.
174-176
: Approved: Uniform implementation ofConfig create
across all factories.The method's implementation is consistent with the new interface requirements, ensuring that configurations can be tailored to specific applications and namespaces.
184-186
: Approved: Uniform implementation ofConfigFile createConfigFile
across all factories.This method enhances the configurability of the system by allowing for the creation of configuration files that are specific to both an application ID and a namespace.
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java (3)
45-45
: Initialization ofConfigUtil
.The direct instantiation of
ConfigUtil
usingApolloInjector
ensures that the configuration utility is properly integrated and managed within the Apollo infrastructure. This is a good use of dependency injection principles.
74-77
: Dynamic addition of namespaces toPropertySourcesProcessor
.This loop effectively adds namespaces for each app ID, ensuring that configurations are dynamically loaded based on the app ID. The use of
Lists.newArrayList
is appropriate here for converting arrays to lists.
Line range hint
19-28
: Review of new imports and dependencies.The addition of
ConfigUtil
and other imports are necessary for the new functionalities introduced. Ensure that these dependencies are properly managed and do not introduce any version conflicts or additional overhead that could affect the application's performance.Verification successful
No Dependency Conflicts with ConfigUtil Import
The import ofConfigUtil
inDefaultApolloConfigRegistrarHelper.java
is consistent with its usage as an internal utility class within the Apollo project. It is managed by theApolloInjector
and does not introduce any external dependency conflicts.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential dependency conflicts. # Test: Search for dependency declarations in build files. Expect: No conflicts with existing dependencies. fd 'pom.xml' --exec cat {} \; | grep 'ConfigUtil'Length of output: 50
Script:
#!/bin/bash # Search for the definition or declaration of ConfigUtil in the codebase ast-grep --lang java --pattern 'class ConfigUtil { $$$ }' # Check if ConfigUtil is part of a library that is already included as a dependency rg 'ConfigUtil' -A 5Length of output: 116958
apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (3)
116-117
: Review the constructor and method changes inMockConfig
.The constructor of
MockConfig
has been correctly updated to includeappId
, aligning with the changes required for supporting multiple app IDs. The methodgetProperty
now correctly formats the return value to includeappId
, which is crucial for ensuring that the configuration keys are correctly formed and tested.Also applies to: 127-127
152-157
: Review the constructor changes inMockConfigFile
.The updated constructor in
MockConfigFile
now acceptsappId
along withnamespace
andconfigFileFormat
, which is essential for testing configurations that are specific to an application ID. This change is well-aligned with the PR's objectives and enhances the specificity of the configuration tests.
206-208
: Review the method changes inMockConfigFactory
.The methods
create
andcreateConfigFile
inMockConfigFactory
have been updated to include anappId
parameter. This modification is crucial for creating configurations that are specific to an application ID, thus supporting the new functionality introduced in the PR. The implementation appears correct and aligns with the changes described in the PR summary.Also applies to: 216-218
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (5)
59-59
: Refactor: Use of Multimap for Namespace ManagementThe change to use a
Multimap
for managing namespaces associated with multiple app IDs is a significant improvement. This structure allows for more flexible and scalable configuration management, especially in environments with multiple applications.
69-70
: Refactor: Static Method Overload for Backward CompatibilityThe addition of an overloaded
addNamespaces
method that defaults to using the current app ID is a good practice for maintaining backward compatibility. This allows existing code to function without modification while supporting new functionality.
72-75
: Enhancement: Support for Multiple App IDs in Namespace ManagementThis method enhancement to handle multiple app IDs is aligned with the PR's objectives. It correctly creates a new multimap for each app ID and associates it with the given namespaces, which is crucial for the new functionality.
120-120
: Cleanup Operation on APP_NAMESPACE_NAMESClearing
APP_NAMESPACE_NAMES
after initialization is a critical operation to ensure that the state does not persist beyond its intended scope. This is a good practice to prevent potential memory leaks or stale data issues.
172-172
: Reset Method EnhancementThe update to the
reset
method to clear bothAPP_NAMESPACE_NAMES
andAUTO_UPDATE_INITIALIZED_BEAN_FACTORIES
is necessary to ensure that all stateful components are correctly reset during testing or reinitialization scenarios.apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (2)
226-226
: Approved: Updated test method reflects changes correctly.The test method
testLocalCacheDirWithSystemProperty
correctly verifies the behavior ofgetDefaultLocalCacheDir(someAppId)
by ensuring theappId
is appended to the cache directory path.
239-243
: Approved: Test method accurately reflects OS-specific behavior with appId.The test method
testDefaultLocalCacheDir
effectively verifies the behavior ofgetDefaultLocalCacheDir(someAppId)
for both Windows and non-Windows systems, ensuring that theappId
is correctly incorporated into the path.apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java (1)
20-20
: Approved: Import and system property setting.The import of
ApolloClientSystemConsts
and the dynamic setting of theAPP_ID
system property are crucial for supporting multiple app IDs. This aligns with the PR's objectives to enhance configuration capabilities.Ensure that the new system property
APP_ID
is utilized consistently across the test suite where applicable.Also applies to: 121-121
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (7)
52-52
: Initialization ofm_appId
The addition of
m_appId
as a class member is consistent with the PR's objective to handle multiple app IDs. This change allows the class to manage configurations based on the application identifier effectively.
66-71
: Constructor Overloading withappId
The constructors have been overloaded to include
appId
, which is essential for distinguishing configurations across different applications. This change aligns well with the PR's objectives and enhances the configurability of the system.
88-88
: Dynamic Local Cache Directory Based onappId
The method
findLocalCacheDir
now dynamically determines the cache directory based onappId
. This is a crucial enhancement for supporting environments with multiple applications, ensuring that each application's configuration is isolated and managed independently.
133-144
: Handling Repository Changes withappId
The method
onRepositoryChange
has been updated to includeappId
. This ensures that changes are correctly associated with the specific application, which is vital for accurate configuration management in multi-application environments.
160-160
: Loading Properties from Local Cache FileThe method
loadFromLocalCacheFile
now includesappId
in its parameters, which is used to construct the cache file name. This modification is necessary to ensure that the cache files are uniquely identified per application, preventing configuration conflicts.
201-201
: Persisting Local Cache File withappId
The method
persistLocalCacheFile
has been updated to includeappId
, enhancing the specificity of cache file management. This change is crucial for maintaining the integrity and isolation of configuration data across multiple applications.Also applies to: 239-239
297-300
: Assembling Local Cache File Name withappId
The method
assembleLocalCacheFile
now constructs the file name usingappId
, which is a necessary change to support unique file naming conventions across different applications. This ensures that configurations are not only isolated by namespace but also by application identifier.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (5)
68-69
: Refactor suggestion: Constructor delegation.The constructor at lines 68-69 delegates to another constructor using
null
forappId
. This is a good use of constructor chaining to maintain a clean and DRY codebase.
78-84
: Review: New constructor with appId.The new constructor introduced at lines 78-84 correctly handles the case where
appId
isnull
by fetching the defaultappId
fromConfigUtil
. This ensures backward compatibility and flexibility in configuration management.
240-241
: Refactor suggestion: Method overloading for backward compatibility.The method
onRepositoryChange
at lines 240-241 is overloaded to maintain backward compatibility while supporting the newappId
parameter. This is a good practice as it allows existing code to function without modification while enabling new functionality.
Line range hint
243-261
: Review: Handling of configuration changes with appId.The method
onRepositoryChange
at lines 243-261 now includes handling for theappId
. This change is crucial for supporting configurations specific to different applications, enhancing the flexibility of the configuration management system.
274-274
: Review: Calculation of property changes.The method
updateAndCalcConfigChanges
at line 274 now includesappId
in the calculation of property changes. This is an important update as it ensures that changes are accurately tracked and managed per application, aligning with the PR's objectives to support multiple app IDs.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (2)
78-80
: Refactor to use ConcurrentHashMap and Table for tracking and notifications.The transition to using
ConcurrentHashMap
form_longPollStarted
andTable
form_notifications
is a significant improvement. This change enhances the granularity of control and allows for app-specific tracking, which is crucial for the feature of handling multiple app IDs. The use ofConcurrentHashMap
ensures thread safety and better performance under concurrent access scenarios.
299-300
: Simplify namespace assembly for app-specific configurations.The
assembleNamespaces
method has been updated to handle app-specific configurations. The method now correctly assembles namespaces based on the app ID. This change is a straightforward adaptation to support the new multi-app functionality and is implemented correctly.apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (1)
524-526
: Review:getAccessKeySecret(String appId)
method implementation.The method
getAccessKeySecret(String appId)
retrieves the access key secret for a specificappId
using theFoundation
class. This is a straightforward implementation that delegates the responsibility to theFoundation.app().getAccessKeySecret(appId)
method.Given the previous comments about integrating this logic into
Foundation.app()
, it appears this change aligns with those suggestions. Ensure that theFoundation
class has been appropriately updated to handle this new method call.Verification successful
Clarification on
getAccessKeySecret
Method ImplementationThe
getAccessKeySecret
method is not directly implemented in theFoundation
class. Instead, it is part of theApplicationProvider
interface and implemented by classes likeDefaultApplicationProvider
. Ensure thatFoundation.app()
correctly delegates to an appropriate provider that implements this method.
DefaultApplicationProvider
implementsgetAccessKeySecret(String appId)
.ApplicationProvider
interface declaresgetAccessKeySecret
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the Foundation class has been updated to handle the new method call. # Test: Search for the updated Foundation class implementation. ast-grep --lang java --pattern $'class Foundation { $$$ getAccessKeySecret($_) { $$$ } $$$ }'Length of output: 108
Script:
#!/bin/bash # Locate the Foundation class in the codebase fd -e java -x grep -l 'class Foundation' {} # Search for the getAccessKeySecret method in the codebase rg 'getAccessKeySecret' -A 3 --glob '*.java'Length of output: 8689
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Show resolved
Hide resolved
.../src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java
Show resolved
Hide resolved
.../src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java
Show resolved
Hide resolved
.../src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
Show resolved
Hide resolved
132e2b7
to
38469c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 18
Outside diff range, codebase verification and nitpick comments (6)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java (1)
32-38
: Review of the new method addition inRepositoryChangeListener
.The addition of the new method
onRepositoryChange(String appId, String namespace, Properties newProperties)
is well-documented and aligns with the PR's objectives to enhance configuration management by supporting multiple app IDs. This method allows for more granular control and differentiation of repository changes per application, which is crucial in multi-application environments.However, it's important to ensure that this change does not break existing implementations. Since this is an interface, adding a new method could break classes that implement this interface unless they are updated accordingly.
Consider providing a default implementation for the new method in the interface to maintain backward compatibility. This can be done using Java 8's default methods in interfaces. Here's a suggested implementation:
default void onRepositoryChange(String appId, String namespace, Properties newProperties) { // Default implementation to avoid breaking existing implementations onRepositoryChange(namespace, newProperties); }This default method simply redirects to the existing
onRepositoryChange(String namespace, Properties newProperties)
method, ensuring that existing implementations that do not yet handleappId
can continue to function without modification.apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1)
38-46
: Approve the addition of thegetAppId()
method.The addition of the
getAppId()
method as a default method in theConfigFile
interface is a good practice for interface evolution. It allows the interface to be extended without breaking existing implementations. The method is well-documented and includes a version annotation, which is helpful for maintainers.However, it's important to ensure that implementations that require a specific appId should override this method to return the correct value instead of
null
.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java (1)
74-77
: Approved: Use ofsomeAppId
in method calls.The changes to include
someAppId
in theConfigChange
constructor andconfig.fireConfigChange
method call are well-implemented. This ensures consistent application ID usage across configuration changes.Consider adding a comment explaining the purpose of
someAppId
for future maintainability.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (1)
Line range hint
243-261
: Enhancement: ExtendedonRepositoryChange
to support appId.This method extension is crucial for handling configuration changes in a multi-app environment. The method correctly checks for changes before proceeding, which is efficient. However, consider adding more detailed logging to help trace the flow of changes, especially in complex environments.
+ logger.debug("Processing repository change for appId: {}, namespace: {}", appId, namespace);
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (1)
Line range hint
128-154
: Review thestartLongPolling
method with app-specific logic.The method has been updated to handle app-specific long polling initiation. The use of
putIfAbsent
to check and set them_longPollStarted
flag is efficient and prevents redundant polling initialization. However, the exception handling within the method could be improved by logging more specific details about the failure context, which would aid in debugging.Consider enhancing the logging detail in the exception handling:
ApolloConfigException exception = new ApolloConfigException("Schedule long polling refresh failed for appId: " + sysAppId, ex);This addition provides clearer context in the logs regarding which app ID encountered the scheduling issue.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (1)
106-108
: Cleanup: Remove commented-out code.The commented-out code related to
PropertySourcesProcessor
is unnecessary and clutters the codebase. Removing this code will improve readability and maintainability.Consider removing the commented-out code unless there is a specific reason to keep it for future reference.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (82)
- CHANGES.md (1 hunks)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (1 hunks)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (7 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEvent.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/JsonConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (8 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PlainTextConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepository.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/TxtConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/XmlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YmlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigFileChangeEvent.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactory.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactoryManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigRegistry.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java (3 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/build/MockInjector.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/integration/ConfigIntegrationTest.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java (30 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepositoryTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java (9 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (15 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/TxtConfigFileTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/YamlConfigFileTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryFileCachePropertyTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java (3 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (7 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (29 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderAutoUpdateTest.java (40 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java (20 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderAutoUpdateTest.java (25 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.java (5 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/CachedCompositePropertySourceTest.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (2 hunks)
- apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/StringUtils.java (1 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java (2 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/NullProvider.java (1 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java (1 hunks)
- apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/ApolloTestingServer.java (2 hunks)
- apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiWhileCacheDirSpecifiedTest.java (1 hunks)
- changes/changes-2.3.0.md (1 hunks)
- pom.xml (1 hunks)
Files skipped from review due to trivial changes (4)
- CHANGES.md
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/build/MockInjector.java
- pom.xml
Files skipped from review as they are similar to previous changes (16)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PlainTextConfigFile.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java
- apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java
Additional comments not posted (237)
changes/changes-2.3.0.md (2)
7-13
: Review of Change EntriesThe entries from line 7 to 13 are well-documented and each includes a direct link to the corresponding pull request, which enhances transparency and traceability. The descriptions are clear and concise, providing a quick overview of the changes made in version 2.3.0.
16-16
: Review of Comprehensive LinkThe link provided on line 16 to view all issues and pull requests associated with this release is correctly formatted and functional. This is a valuable resource for users looking for a comprehensive view of the development process for version 2.3.0.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/TxtConfigFile.java (2)
Line range hint
27-29
: MethodgetConfigFileFormat
remains unchanged.The method
getConfigFileFormat
which returnsConfigFileFormat.TXT
is unchanged and continues to function as expected. This method is not directly affected by the constructor change.
23-24
: Constructor updated to includeappId
.The constructor of
TxtConfigFile
now includes an additional parameterappId
, which is passed to the superclassPlainTextConfigFile
. This change aligns with the PR's objective to support multiple app IDs and enhances configuration management capabilities. However, it is crucial to ensure that all instantiations ofTxtConfigFile
across the codebase are updated to reflect this new parameter.Verification successful
All instantiations of
TxtConfigFile
updated successfully.The constructor change to include the
appId
parameter inTxtConfigFile
has been successfully propagated across the codebase. Both the production and test code reflect the new constructor signature, ensuring consistency and alignment with the PR's objectives.
DefaultConfigFactory.java
: Updated to use the new constructor signature.TxtConfigFileTest.java
: Updated to use the new constructor signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instantiations of `TxtConfigFile` are updated to include the new `appId` parameter. # Test: Search for instantiations of `TxtConfigFile`. Expect: Only occurrences with the new constructor signature. rg --type java -A 5 $'new TxtConfigFile'Length of output: 1503
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YmlConfigFile.java (2)
25-26
: Constructor signature change is well-implemented.The addition of the
appId
parameter to the constructor ofYmlConfigFile
is correctly implemented. Thesuper
call has been appropriately updated to pass this new parameter along with the existing ones. This change supports the PR's objective of enhancing configuration capabilities by allowing multiple app IDs.
25-26
: Verify the impact on existing code.Given the change in the constructor signature, it is crucial to ensure that all existing code that instantiates
YmlConfigFile
is updated to pass the newappId
parameter. This might involve significant changes across the codebase.Run the following script to verify the usage of
YmlConfigFile
constructor:Verification successful
Verification Successful: All instantiations of
YmlConfigFile
use the new constructor signature.The instantiation of
YmlConfigFile
inDefaultConfigFactory.java
includes theappId
parameter, and no other outdated usages were found in the codebase. The update appears to be correctly applied across the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instantiations of `YmlConfigFile` to ensure they include the new `appId` parameter. # Test: Search for the constructor usage. Expect: Only occurrences with the new signature. rg --type java -A 5 $'new YmlConfigFile'Length of output: 731
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/XmlConfigFile.java (3)
25-27
: Constructor changes are correctly implemented.The updated constructor now correctly passes the
appId
,namespace
, andconfigRepository
parameters to the superclass constructor. This change is essential for supporting multiple app IDs and aligns with the PR's objectives.
Line range hint
29-31
: Config file format method remains correct.The
getConfigFileFormat
method correctly returnsConfigFileFormat.XML
, which is appropriate for theXmlConfigFile
class. No changes were needed here, and the method continues to function as expected.
25-27
: Verify the usage of the new constructor across the codebase.The constructor of
XmlConfigFile
now includes anappId
parameter. It is crucial to ensure that all instantiations ofXmlConfigFile
across the codebase are updated to pass this new parameter.Run the following script to verify the constructor usage:
Verification successful
Constructor usage correctly updated across the codebase.
The
XmlConfigFile
constructor has been updated to include anappId
parameter, and all instances of its usage in both test and main code have been correctly updated to reflect this change. No further action is required.
XmlConfigFileTest.java
shows multiple instances of the updated constructor.DefaultConfigFactory.java
also uses the updated constructor.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instantiations of `XmlConfigFile` include the new `appId` parameter. # Test: Search for the constructor usage. Expect: Only occurrences with the new signature. rg --type java -A 5 $'new XmlConfigFile'Length of output: 6186
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/JsonConfigFile.java (2)
25-27
: Constructor change aligns with PR objectives.The modification to include an
appId
parameter in the constructor ofJsonConfigFile
aligns with the PR's objective to support multiple app IDs. This change enhances the configuration management capabilities by allowing configurations to be associated with specific applications.
25-27
: Verify the impact of the constructor change on other parts of the system.The addition of the
appId
parameter to the constructor is a significant change. It is crucial to ensure that all parts of the system that instantiateJsonConfigFile
are updated to pass the newappId
parameter. This change should be verified to ensure it does not break existing functionality.Run the following script to verify the usage of
JsonConfigFile
constructor across the codebase:Verification successful
Constructor change verification successful.
The addition of the
appId
parameter to theJsonConfigFile
constructor has been successfully integrated across the codebase. All instances of the constructor usage have been updated to include the new parameter, and the changes are reflected in both test and production code. No issues were found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instantiations of `JsonConfigFile` include the new `appId` parameter. # Test: Search for the constructor usage. Expect: Only occurrences with the new signature. rg --type java -A 5 $'new JsonConfigFile'Length of output: 4780
apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java (1)
30-31
: Verify the usage of the new method signature across the codebase.The method
createRepositoryConfig
now includes an additional parameterappId
. It is crucial to ensure that all references to this method in the codebase have been updated to pass the new parameter. This change could potentially break existing functionality if not handled correctly.Run the following script to verify the method usage:
Verification successful
Verification successful: Method signature update is correctly implemented.
The
createRepositoryConfig
method's signature change to include theappId
parameter has been verified. The method is used consistently with the new signature in the codebase, particularly in theDefaultConfigFactory
class. No instances of the old signature were found, indicating that the update has been correctly propagated.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `createRepositoryConfig` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'createRepositoryConfig'Length of output: 2301
apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java (1)
55-57
: Address potential NullPointerException by providing a safer return value.The method
getAccessKeySecret(String appId)
currently returnsnull
, which could lead toNullPointerException
in the calling code. It's important to handle this case more robustly. Consider implementing one of the following solutions:
- Return an empty string if the access key is not available, which avoids
NullPointerException
and allows calling code to handle the absence of a key gracefully.- Throw a specific exception if the access key cannot be retrieved, which makes the error handling explicit and informs the caller of the issue.
Here are the proposed changes:
default String getAccessKeySecret(String appId) { - return null; + return ""; // Option 1: Return an empty string }Or:
default String getAccessKeySecret(String appId) { - return null; + throw new UnsupportedOperationException("Access key secret not available"); // Option 2: Throw an exception }Likely invalid or redundant comment.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigRegistry.java (2)
33-40
: Review of the newregister
method withappId
.The addition of the
appId
parameter to theregister
method is a significant enhancement that aligns with the PR's objectives to support multiple app IDs. This change allows for more granular control over configuration management, especially in environments with multiple applications.
- Correctness: The method signature and JavaDoc comments are correctly defined.
- Consistency: This method complements the existing
register
method by adding anappId
parameter, which is consistent with the need for handling multiple applications.- Documentation: The JavaDoc is clear and provides adequate information about the parameters and their purpose.
Overall, this is a well-implemented change that enhances the interface's functionality.
50-57
: Review of the newgetFactory
method withappId
.Similar to the
register
method, the addition of theappId
parameter to thegetFactory
method enhances the interface's capability to handle configurations for multiple applications. This method allows retrieving the configuration factory based on bothappId
andnamespace
, which is crucial for environments where configurations are specific to each application.
- Correctness: The method signature and JavaDoc comments are correctly defined.
- Consistency: This method complements the existing
getFactory
method by adding anappId
parameter, maintaining consistency in the interface's design.- Documentation: The JavaDoc clearly explains the purpose of the parameters and the method's functionality.
This change is well-aligned with the PR's objectives and is implemented correctly.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactory.java (2)
35-42
: Approved: New method for app-specific configuration.The addition of
Config create(String appId, String namespace)
method is well-implemented and documented. It enhances the flexibility of the configuration system by allowing configurations to be specific to an application ID and namespace.Ensure that existing implementations that use the old
create(String namespace)
method are not adversely affected by this change.
51-57
: Approved: Enhanced method for creating config files with app context.The addition of
ConfigFile createConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
method is well-implemented and documented. It allows for the creation of configuration files that are specific to an application ID, namespace, and configuration file format, enhancing the system's usability and flexibility.Ensure that existing implementations that use the old
createConfigFile(String namespace, ConfigFileFormat configFileFormat)
method are not adversely affected by this change.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEvent.java (2)
44-46
: Review of Constructor ChangesThe constructor of
InterestedConfigChangeEvent
has been modified to include an additional parameterappId
. This change is consistent with the PR's objective to support multiple app IDs. The updated constructor correctly initializes the superclass with this new parameter, ensuring that theappId
is now part of the event context.This modification enhances the flexibility of the configuration change event handling by allowing events to be associated with specific applications. It is crucial to ensure that all parts of the system that instantiate this class are updated to pass the new
appId
parameter to avoid runtime errors.
Line range hint
54-56
: Review of MethodinterestedChangedKeys
The method
interestedChangedKeys
remains unchanged and continues to function as expected. It correctly returns an unmodifiable set of the keys that triggered the change event, which is a good practice to ensure data integrity and prevent unintended modifications.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/TxtConfigFileTest.java (2)
34-34
: Approved: Addition ofsomeAppId
variable.The introduction of the
someAppId
variable is well-aligned with the PR's objectives to support multiple app IDs. It is correctly declared and initialized in thesetUp
method.
41-41
: Approved: Initialization insetUp
method.The initialization of
someAppId
andsomeNamespace
in thesetUp
method ensures that each test case starts with a consistent and isolated environment, which is a best practice in unit testing.apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/NullProvider.java (1)
87-90
: Approved: New methodgetAccessKeySecret(String appId)
The addition of the method
getAccessKeySecret(String appId)
is consistent with the class's design of returning default values. The implementation correctly adheres to the expected behavior of the interface, enhancing the class's compliance without altering its existing functionality.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepository.java (1)
46-46
: Verify integration and impact of the newappId
parameter infireRepositoryChange
.The addition of
configFile.getAppId()
as a parameter tofireRepositoryChange
enhances the granularity of configuration change tracking. However, it is crucial to verify that this change integrates seamlessly with the existing system and does not introduce any unintended side effects.Run the following script to verify the usage of the new method signature across the codebase:
Verification successful
Integration of
appId
parameter infireRepositoryChange
is consistent and complete.The addition of
configFile.getAppId()
to thefireRepositoryChange
method is consistently applied across the codebase, ensuring seamless integration without any unintended side effects.
- The method is used with the new signature in
RemoteConfigRepository
,PropertiesCompatibleFileConfigRepository
, andLocalFileConfigRepository
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new `fireRepositoryChange` method signature across the codebase. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'fireRepositoryChange'Length of output: 3269
apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigFileChangeEvent.java (4)
26-26
: Clarification needed for the addition ofappId
.Based on the previous comment by nobodyiam questioning the absence of a
getAppId
method, it appears that the addition of theappId
field and its corresponding getter method in this PR addresses that concern. However, it would be beneficial to confirm that this addition aligns with the intended design and usage within the broader application context.
50-52
: Approval of the newgetAppId
method.The addition of the
getAppId
method is a straightforward implementation that provides access to theappId
field. This method enhances the class's interface by allowing external access to theappId
, which is crucial for handling configurations specific to different applications.
73-74
: Review oftoString
method updates.The
toString
method is updated to include theappId
in its output. This change ensures that the string representation of the class instances now accurately reflects the new state of the object, including theappId
. This is particularly useful for logging and debugging purposes, where a complete description of the event is necessary.
35-43
: Review of constructor changes.The constructor now includes
appId
as the first parameter, which is a significant change as it affects how instances ofConfigFileChangeEvent
are created throughout the application. This change is aligned with the PR's objective to support multiple app IDs. Ensure that all instantiations of this class in the codebase are updated to reflect this new parameter order.Verification successful
Constructor changes verified successfully.
The instantiation of
ConfigFileChangeEvent
in the codebase has been updated to includeappId
as the first parameter, aligning with the new constructor signature. No other instances were found that require modification.
AbstractConfigFile.java
: Correct usage of the new constructor signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instantiations of `ConfigFileChangeEvent` are updated to include `appId`. # Test: Search for the constructor usage. Expect: Only occurrences with the new signature. rg --type java -A 5 $'new ConfigFileChangeEvent'Length of output: 774
Script:
#!/bin/bash # Description: Search for all instantiations of `ConfigFileChangeEvent` to ensure they use the new constructor signature. # Test: Search for all occurrences of `ConfigFileChangeEvent` instantiation. rg --type java 'new ConfigFileChangeEvent'Length of output: 241
apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (3)
28-28
: Field addition approved.The addition of the
private final String m_appId;
field is appropriate for maintaining immutability and encapsulation in the class.
78-84
: Method addition approved.The addition of the
getAppId()
method is a standard practice for providing external access to private fields in Java. This method correctly returns them_appId
field.
36-38
: Verify the impact of constructor parameter order change.The constructor now includes an additional parameter
appId
, which is correctly initialized. However, this change in parameter order could impact existing code where this constructor is used.Run the following script to verify the constructor usage:
Verification successful
Constructor parameter order change verified successfully.
The constructor
ConfigChangeEvent
is only used in test files, and all instances match the new signature with three parameters. There is no impact on production code.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `ConfigChangeEvent` match the new signature. # Test: Search for the constructor usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'new ConfigChangeEvent'Length of output: 3495
Script:
#!/bin/bash # Description: Verify all constructor calls to `ConfigChangeEvent` across the entire codebase to ensure they match the new signature. # Test: Search for the constructor usage across all Java files. Expect: Only occurrences of the new signature. rg --type java -A 5 $'new ConfigChangeEvent'Length of output: 3495
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java (2)
66-69
: Approved: Newcreate
method overload withappId
.The addition of the
appId
parameter in thecreate
method is correctly implemented and aligns with the PR objectives to enhance configuration capabilities.
76-79
: Approved: NewcreateConfigFile
method overload withappId
.The addition of the
appId
parameter in thecreateConfigFile
method is correctly implemented and aligns with the PR objectives to enhance configuration capabilities.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (1)
66-69
: Review of the ModifiedfireRepositoryChange
MethodThe addition of the
appId
parameter to thefireRepositoryChange
method is a significant enhancement that aligns with the PR's objectives to support multiple app IDs. This change allows the method to provide more contextual information about the application associated with the configuration change, which is crucial for systems managing configurations across multiple applications.Key Observations:
- The method now iterates over
m_listeners
and invokesonRepositoryChange
on each listener with the newappId
parameter.- Exception handling within the loop is robust, logging the error and continuing with the next listener, which ensures that a failure in one listener does not halt the notification process for others.
Suggestions:
- **** Ensure that all implementations of
RepositoryChangeListener
have been updated to handle the new method signature. This is crucial to prevent runtime method signature mismatches.- **** Consider adding more detailed logging at the debug level to trace the values of
appId
,namespace
, andnewProperties
being passed to each listener. This could be valuable for troubleshooting and verifying that the correct data is being used.- **** If there are any concerns about how to update the listeners or if additional testing is required, I can assist with these updates or provide guidance on setting up appropriate tests.
Verification successful
Verification of
onRepositoryChange
Method Signature UpdateThe implementations of
RepositoryChangeListener
have been updated to handle the newonRepositoryChange
method signature with theappId
parameter. The presence of both method signatures in theRepositoryChangeListener
interface ensures backward compatibility. Test files have been updated to verify the new functionality.
- Implementations Updated:
LocalFileConfigRepository
,AbstractConfigFile
,SimpleConfig
,DefaultConfig
.- Tests Updated:
JsonConfigFileTest
,XmlConfigFileTest
,DefaultConfigTest
,SimpleConfigTest
,RemoteConfigRepositoryTest
, and others.The changes align with the PR's objectives to support multiple app IDs, and the backward compatibility is maintained. No further action is required.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all implementations of RepositoryChangeListener handle the new method signature. # Test: Search for implementations of RepositoryChangeListener. Expect: Updated method signatures. rg --type java -A 5 $'onRepositoryChange'Length of output: 63127
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1)
73-78
: Well-documented addition ofmultipleConfigs()
method.The addition of the
multipleConfigs()
method is well-documented and clearly explains its purpose and non-participation in the bootstrap process. The use of the@since
tag is a good practice, helping track the introduction of new features. The default value being an empty array ensures backward compatibility.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java (1)
39-41
: Review the modified constructor with the newappId
parameter.The addition of the
appId
parameter to the constructor is a significant change that aligns with the PR's objectives to support multiple app IDs. This change allows for more granular control over configurations per application. Ensure that:
- The superclass
AbstractConfigFile
has been modified to accept this new parameter.- All instantiations of
PropertiesConfigFile
throughout the codebase are updated to include theappId
parameter.Run the following script to verify the superclass modification and usage of the new constructor:
Verification successful
Superclass
AbstractConfigFile
supports the newappId
parameter.The
AbstractConfigFile
constructor has been updated to accept theappId
parameter, ensuring compatibility with the changes made to thePropertiesConfigFile
constructor. The codebase has been updated to use the new constructor signature where necessary.
- The
AbstractConfigFile
constructor now includesappId
,namespace
, andconfigRepository
parameters.- Instantiations of
PropertiesConfigFile
have been updated to pass theappId
parameter.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the superclass and usage of the new constructor. # Test: Search for the superclass constructor modification. ast-grep --lang java --pattern $'class AbstractConfigFile { $$$ AbstractConfigFile($_, $_, $_) { $$$ } $$$ }' # Test: Search for the usage of the new constructor. rg --type java -A 5 $'new PropertiesConfigFile'Length of output: 7018
Script:
#!/bin/bash # Description: Verify the implementation of AbstractConfigFile to check for appId support. # Search for the AbstractConfigFile class definition and its constructor. ast-grep --lang java --pattern $'class AbstractConfigFile { $$$ AbstractConfigFile($$$) { $$$ } $$$ }'Length of output: 117
Script:
#!/bin/bash # Description: Locate the AbstractConfigFile.java file and inspect its constructor. # Find the AbstractConfigFile.java file and display its contents. fd -e java -x bash -c 'echo "File: {}"; cat {}' | grep -A 10 'class AbstractConfigFile'Length of output: 747
Script:
#!/bin/bash # Description: Search for the constructor of AbstractConfigFile to verify its parameters. # Find the AbstractConfigFile.java file and search for its constructor. fd -e java -x bash -c 'echo "File: {}"; cat {}' | grep -A 10 'AbstractConfigFile('Length of output: 767
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java (2)
39-40
: Proper Error Handling intryTransformToProperties
The method
tryTransformToProperties
demonstrates good error handling practices by catching exceptions, logging them appropriately, and returning a boolean status. This ensures that the application can gracefully handle errors during the properties transformation process.
39-40
: Constructor Signature Change: Ensure CompatibilityThe constructor of
YamlConfigFile
now includes anappId
parameter. This is a significant change that enhances the class's functionality by allowing it to handle configurations specific to an application ID. Ensure that all instantiations ofYamlConfigFile
across the codebase are updated to pass this new parameter.Run the following script to verify the constructor usage:
Verification successful
Constructor Signature Change Verified
The constructor of
YamlConfigFile
has been successfully updated to include theappId
parameter across the codebase. All instances ofYamlConfigFile
creation, including those in test files and the main source fileDefaultConfigFactory.java
, have been correctly modified to use the new constructor signature. No further action is required.
- Instances in
AbstractSpringIntegrationTest.java
andYamlConfigFileTest.java
confirm the update in test scenarios.- The update in
DefaultConfigFactory.java
confirms the change in production code.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `YamlConfigFile` match the new signature. # Test: Search for the constructor usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'new YamlConfigFile'Length of output: 7131
apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiWhileCacheDirSpecifiedTest.java (1)
60-60
: Review: Updated constructor call forLocalFileConfigRepository
.The change to the constructor of
LocalFileConfigRepository
from a single argument to two arguments (someAppId, someNamespace
) is consistent with the PR's objective to support multiple app IDs. This update is crucial for ensuring that the configuration repository can handle configurations specific to an application ID alongside the namespace.However, it's essential to verify that this change integrates well with the rest of the system, especially since it affects how configurations are loaded and managed. The test should ensure that the new functionality does not disrupt existing functionalities and that it aligns with the overall system architecture.
Verification successful
Verified: Consistent use of the new constructor for
LocalFileConfigRepository
.The constructor change to
LocalFileConfigRepository(someAppId, someNamespace)
is consistently applied across the codebase, including both main and test files. This indicates that the new functionality is well-integrated and adequately tested, aligning with the PR's objective to support multiple app IDs.
- Files with updated constructor usage:
ApolloTestingServer.java
ApolloMockServerApiWhileCacheDirSpecifiedTest.java
LocalFileConfigRepositoryTest.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new constructor is used consistently across the project. # Test: Search for the constructor usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'new LocalFileConfigRepository'Length of output: 8309
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryFileCachePropertyTest.java (3)
41-41
: Approved: Introduction ofsomeAppId
.The addition of
someAppId
enhances the flexibility of the test setup by allowing dynamic configuration of the app ID, aligning with the PR's objectives.Also applies to: 46-46
58-58
: Approved: Correct usage ofsomeAppId
in enabled file caching scenario.The dynamic passing of
someAppId
tocreateLocalConfigRepository
is correctly implemented and verified. Consider verifying the integration of this change with other parts of the system to ensure overall compatibility.Also applies to: 61-62
70-70
: Approved: Correct usage ofsomeAppId
in disabled file caching scenario.The dynamic passing of
someAppId
tocreateRemoteConfigRepository
is correctly implemented and verified. Consider verifying the integration of this change with other parts of the system to ensure overall compatibility.Also applies to: 74-74
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java (2)
45-45
: Approved: Addition ofsomeAppId
variable.The addition of the
someAppId
variable aligns with the PR's objective to support multiple app IDs and enhances maintainability by centralizing the app ID value.
Line range hint
45-77
: Summary: Well-integrated changes.The changes made in the
InterestedConfigChangeEventTest
class are well-integrated and align with the PR's objectives to support multiple app IDs. The use ofsomeAppId
enhances the flexibility and maintainability of the test configurations.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepositoryTest.java (3)
43-43
: Approved: Addition ofsomeAppId
variable.The addition of the
someAppId
variable is consistent with the PR's objective to enhance configuration capabilities by supporting multiple app IDs.
51-53
: Approved: Changes in thesetUp
method.The initialization of
someAppId
and the update to thewhen
clause forconfigFile.getAppId()
are well-implemented to support the new functionality of handling multiple app IDs in the configuration.
135-135
: Approved: Changes in thetestOnChange
method.The modification to include
someAppId
in theonRepositoryChange
method call is correctly implemented to test the new behavior of handling multiple app IDs.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/CachedCompositePropertySourceTest.java (4)
Line range hint
29-48
: Setup method is correctly implemented.The
setUp
method properly initializes the test environment with necessary mocks and listener setups.
Line range hint
95-99
: Property source addition and listener registration are correctly tested.The
testAddPropertySource
method correctly verifies the addition of property sources and the registration of listeners.
Line range hint
101-120
: First property source addition and listener registration are correctly tested.The
testAddFirstPropertySource
method correctly tests the addition of a property source at the beginning and ensures that listeners are correctly added.
85-85
: Verify the updatedonChange
method invocation.The change to pass three
null
parameters in theonChange
method needs verification to ensure it aligns with the intended functionality and does not alter the expected behavior of the test.Run the following script to verify the method signature and its usage:
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java (6)
Line range hint
42-51
: Setup method correctly initializessomeAppId
.The introduction of
someAppId
in thesetUp
method is correctly implemented and crucial for testing the new functionality.
67-67
: Correct usage of updated constructor intestWhenHasContent
.The test method
testWhenHasContent
correctly uses the updatedJsonConfigFile
constructor with the newsomeAppId
parameter.
80-80
: Correct usage of updated constructor intestWhenHasNoContent
.The test method
testWhenHasNoContent
correctly uses the updatedJsonConfigFile
constructor with the newsomeAppId
parameter.
90-90
: Correct usage of updated constructor intestWhenConfigRepositoryHasError
.The test method
testWhenConfigRepositoryHasError
correctly uses the updatedJsonConfigFile
constructor with the newsomeAppId
parameter.
Line range hint
110-121
: Correct usage of updated method signature intestOnRepositoryChange
.The test method
testOnRepositoryChange
correctly uses the updatedonRepositoryChange
method with the newsomeAppId
parameter.
139-145
: Correct usage of updated constructor and method intestWhenConfigRepositoryHasErrorAndThenRecovered
.The test method
testWhenConfigRepositoryHasErrorAndThenRecovered
correctly uses the updatedJsonConfigFile
constructor andonRepositoryChange
method with the newsomeAppId
parameter.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (5)
48-48
: Constructor and Field Initialization ApprovedThe addition of the
m_appId
field and its initialization in the constructor are correctly implemented to support multiple app IDs as per the PR's objectives.Also applies to: 61-63
85-88
: New MethodgetAppId()
ApprovedThe implementation of the
getAppId()
method is correct and provides a necessary accessor for them_appId
field.
99-100
: Incorporation of Suggested ChangeThe change suggested by nobodyiam has been successfully incorporated into the new
onRepositoryChange
method.
99-100
: Modified MethodonRepositoryChange
ApprovedThe changes to the
onRepositoryChange
method correctly incorporate the application ID into configuration change events. It is recommended to verify the integration of this method with other components that handle configuration changes.Also applies to: 102-125
Verification successful
Integration of
onRepositoryChange
Method VerifiedThe
onRepositoryChange
method, with the newappId
parameter, is well-integrated and tested across various components in the codebase. The test cases confirm its correct functionality in different scenarios. No further action is required.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of the new `onRepositoryChange` method with other components. # Test: Search for method usage in other components. Expect: Proper handling of the new method signature. rg --type java -A 5 $'onRepositoryChange'Length of output: 63127
Line range hint
48-125
: Overall Changes ApprovedThe modifications in the
AbstractConfigFile
class are well-integrated and consistent with the PR's objectives to handle multiple app IDs. It is recommended to conduct further testing to ensure robustness and compatibility.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java (1)
46-46
: Addition ofsomeAppId
variable.The introduction of the
someAppId
variable aligns with the PR's objective to handle multiple app IDs. This variable is used effectively across the test configurations and method signatures to simulate a multi-app environment.Also applies to: 54-54
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java (5)
52-52
: Addition ofsomeAppId
instance variable.The addition of the
someAppId
variable is consistent with the PR's objective to support multiple app IDs. This change is crucial for the new functionality and is well-integrated into the existing test setup.
62-62
: Initialization ofsomeAppId
in thesetUp
method.The initialization of
someAppId
in thesetUp
method ensures that it is available for all tests, supporting the new constructor signature ofSimpleConfig
. This is a necessary change to accommodate the new functionality.
91-91
: Updated constructor calls to includesomeAppId
.The constructor of
SimpleConfig
has been updated across multiple test methods (testGetProperty
,testLoadConfigFromConfigRepositoryError
,testOnRepositoryChange
) to include the newsomeAppId
parameter. This change is necessary to test the new functionality introduced in the PR and ensures that theSimpleConfig
class can handle configurations for specific applications.Also applies to: 104-104, 138-138
147-147
: UpdatedonRepositoryChange
method to passsomeAppId
.The
onRepositoryChange
method now correctly passessomeAppId
as an argument, reflecting the updated constructor requirements. This change is crucial for ensuring that the configuration changes are correctly propagated and handled within the application context.
151-151
: Updated assertions to verifysomeAppId
.The assertions in the
testOnRepositoryChange
method have been updated to verify that thechangeEvent
correctly reflects the newsomeAppId
value. This is an important update to ensure that the tests accurately check the functionality related to handling multiple app IDs.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java (4)
47-47
: Approved: Introduction ofsomeAppId
variable.The introduction of the
someAppId
variable centralizes the application ID, enhancing maintainability and reducing the risk of hardcoded strings. This change aligns well with the PR's objectives.
111-112
: Approved: Consistent use ofsomeAppId
.The consistent use of
someAppId
in theConfigChange
andConfigChangeEvent
objects across different test methods supports the PR's objective and enhances configuration flexibility.
156-158
: Approved: Consistent use ofsomeAppId
.The consistent use of
someAppId
in theConfigChange
andConfigChangeEvent
objects across different test methods supports the PR's objective and enhances configuration flexibility.
68-72
: Approved: Use ofsomeAppId
in test method.The use of
someAppId
in creatingConfigChange
andConfigChangeEvent
objects, and the new call tofireConfigChange
enhance flexibility and maintain consistency. Ensure that the new method signature forfireConfigChange
is correctly implemented across the codebase.Verification successful
Verified: Consistent usage of
fireConfigChange
method signature.The
fireConfigChange
method with the new signature is used consistently across the codebase, and the use ofsomeAppId
in the test method aligns with the defined method signature. No issues were found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the new method signature for `fireConfigChange` is used consistently. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'fireConfigChange'Length of output: 11103
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (5)
53-54
: Addition ofsomeAppId
constant.The introduction of a constant for
someAppId
is a good practice as it avoids hardcoding the same string multiple times across the test methods. This change enhances maintainability and readability.
58-59
: SettingsomeAppId
as a system property insetUp
.Setting the
appId
as a system property is crucial for the tests that depend on this configuration. This setup ensures that the environment is correctly prepared for the tests to run under the conditions that mimic the actual usage of the application with the specifiedappId
.
Line range hint
81-107
: Enhanced test cases withsomeAppId
.The modifications in the
testInitializePropertySources
method to includesomeAppId
in the configuration and assertions are aligned with the new functionality of handling multiple app IDs. These changes ensure that the tests are robust and accurately reflect the expected behavior when different app IDs are used.
- The use of
someAppId
inmockConfig
calls ensures that the configuration is correctly mocked with respect to the application ID.- The assertions have been updated to check for the correct formation of property source names, which now incorporate the application ID.
This thorough testing approach helps in validating the functionality introduced in the PR.
113-116
: Testing application event handling withsomeAppId
.The changes in the
testApplicationEvent
method to includesomeAppId
in the configuration and event handling tests are appropriate. This ensures that the application events are correctly processed when different app IDs are used, which is crucial for the new feature's functionality.
- The
mockConfig
call withsomeAppId
ensures that the configuration is correctly set up for the test.- The handling of the
ConfigChangeEvent
and the publishing of theApolloConfigChangeEvent
are critical to ensure that the system reacts appropriately to configuration changes.These tests are essential for verifying that the application's event system works correctly with multiple app IDs.
161-161
: Assertion on system properties override.The assertion in the
testOverrideSystemProperties
method that checks the name of the first property source ensures that the system properties are correctly overridden as specified by the configuration. This is an important aspect of the configuration system that needs to be tested to ensure that the application behaves as expected under different configuration settings.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (9)
67-68
: Refactor: Simplify method delegation.The method
create(String namespace)
now delegates tocreate(String appId, String namespace)
using theappId
fetched fromConfigUtil
. This is a clean implementation that maintains backward compatibility by using the defaultappId
.
Line range hint
70-91
: Review: Core configuration creation logic with appId.The method
create(String appId, String namespace)
has been refactored to include theappId
parameter. This change allows for more granular control over configurations per application. The logic inside the method correctly handles differentConfigFileFormat
types and delegates to the appropriate repository creation methods based on the format compatibility.
93-95
: Refactor: Simplify method delegation for ConfigFile creation.The method
createConfigFile(String namespace, ConfigFileFormat configFileFormat)
now delegates tocreateConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
using theappId
fetched fromConfigUtil
. This maintains backward compatibility and simplifies the API for clients that do not need to specify anappId
.
98-117
: Review: Enhanced ConfigFile creation with appId.The method
createConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
has been updated to handle different file formats and create the appropriateConfigFile
instances using theappId
. This change ensures that configuration files are correctly associated with their respective applications, enhancing the system's ability to manage configurations in a multi-application environment.
123-127
: Review: ConfigRepository creation logic with appId.The method
createConfigRepository(String appId, String namespace)
has been updated to decide between local and remote repositories based on the property file cache setting. This method now correctly uses theappId
to create the appropriate repository, ensuring that configurations are managed per application.
133-144
: Review: LocalFileConfigRepository creation with appId.The method
createLocalConfigRepository(String appId, String namespace)
has been updated to include theappId
in its signature and logic. This change is crucial for ensuring that local configurations are correctly associated with the specified application, especially in environments where Apollo is running in local mode.
147-148
: Review: RemoteConfigRepository creation with appId.The method
createRemoteConfigRepository(String appId, String namespace)
now correctly uses theappId
to create a remote configuration repository. This change is essential for ensuring that remote configurations are managed per application, aligning with the overall goal of enhancing configuration management in multi-application environments.
152-153
: Review: PropertiesCompatibleFileConfigRepository creation with appId.The method
createPropertiesCompatibleFileConfigRepository(String appId, String namespace, ConfigFileFormat format)
now includes theappId
in its logic, ensuring that the properties-compatible configuration files are correctly associated with the specified application. This method correctly handles the namespace formatting based on the file format and application ID, enhancing the flexibility and accuracy of configuration management.
172-172
: Review: Namespace trimming with appId.The method
trimNamespaceFormat(String appId, String namespaceName, ConfigFileFormat format)
has been updated to include theappId
in its logic. This change ensures that the namespace is correctly formatted per application, which is crucial for maintaining consistency and accuracy in configuration file naming and management.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java (7)
Line range hint
51-60
: Initialization ofsomeAppId
is correct.The setup method correctly initializes
someAppId
, which is essential for the tests to accurately reflect the new constructor parameter.
85-85
: Test method update is correct.The update to include
someAppId
in thePropertiesConfigFile
constructor call is correctly implemented in thetestWhenHasContent
method.
97-97
: Test method update is correct.The update to include
someAppId
in thePropertiesConfigFile
constructor call is correctly implemented in thetestWhenHasNoContent
method.
107-107
: Test method update is correct.The update to include
someAppId
in thePropertiesConfigFile
constructor call is correctly implemented in thetestWhenConfigRepositoryHasError
method.
123-123
: Test method update is correct.The update to include
someAppId
in thePropertiesConfigFile
constructor call is correctly implemented in thetestOnRepositoryChange
method.
162-162
: Test method update is correct.The update to include
someAppId
in thePropertiesConfigFile
constructor call is correctly implemented in thetestWhenConfigRepositoryHasErrorAndThenRecovered
method.
182-182
: Test method updates are correct.The updates to include
someAppId
in thePropertiesConfigFile
constructor calls are correctly implemented in thetestIfCompatibleWithProperties
andtestIfCompatibleWithEmptyProperties
methods.Also applies to: 197-197
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (2)
59-59
: Refactor: Use of Multimap for Namespace ManagementThe introduction of
APP_NAMESPACE_NAMES
as aMultimap
to manage namespaces associated with multiple app IDs is a significant improvement. This change aligns with the PR's objective to support multiple app IDs and enhances the flexibility of namespace management.
172-172
: Consistency Maintained in Reset MethodThe update to the
reset
method to clearAPP_NAMESPACE_NAMES
ensures that the new data structure is properly reset, maintaining consistency across the class.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.java (6)
39-39
: Introduction ofsomeAppId
variable.The introduction of the
someAppId
variable is a positive change as it centralizes the application ID, making the tests more maintainable and adaptable to changes in configuration. This aligns with the PR's objective to handle multiple app IDs.
66-66
: Proper use ofsomeAppId
inmockConfig
.The replacement of the hardcoded namespace with
someAppId
in themockConfig
call is correctly implemented and enhances the flexibility of the configuration.
74-74
: Consistent use ofsomeAppId
inmockConfig
.Using
someAppId
in themockConfig
method call maintains consistency and supports the PR's goal of flexible configuration management.
88-88
: Correct implementation ofsomeAppId
inmockConfig
.The use of
someAppId
in themockConfig
call is correctly implemented, enhancing the test's adaptability to configuration changes.
101-106
: Flexible use ofsomeAppId
across different namespaces.The use of
someAppId
for different namespaces within the same test method effectively demonstrates the enhanced flexibility and adaptability of the configuration system.
117-122
: Consistent and flexible use ofsomeAppId
in preparation method.The use of
someAppId
in theprepare
method for different namespaces is consistent with its usage in other test methods, supporting the PR's objectives of enhanced configuration flexibility.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java (5)
122-122
: Approved: Constructor updated to includesomeAppId
.The update to include
someAppId
in the constructor call aligns with the PR objectives. Consider adding specific tests to verify the behavior whensomeAppId
is different or not set.
138-138
: Approved: Constructor updated to includesomeAppId
with fallback repository.The update to include
someAppId
in the constructor call aligns with the PR objectives. Consider adding specific tests to verify the behavior whensomeAppId
is different or not set, especially in the presence of a fallback repository.
150-150
: Approved: Constructor updated to includesomeAppId
for scenarios without a local file.The update to include
someAppId
in the constructor call aligns with the PR objectives. Consider adding specific tests to verify the behavior whensomeAppId
is different or not set, particularly when there is no local file.
164-164
: Approved: Constructor updated to includesomeAppId
for multiple access scenarios.The updates to include
someAppId
in the constructor calls align with the PR objectives. Consider adding specific tests to verify the behavior whensomeAppId
is different or not set, especially when accessing the local file multiple times.Also applies to: 171-171
187-187
: Approved: Constructor and method updated to includesomeAppId
for repository change scenarios.The updates to include
someAppId
in the constructor call andonRepositoryChange
method align with the PR objectives. Consider adding specific tests to verify the behavior whensomeAppId
is different or not set, particularly when the repository changes.Also applies to: 204-204
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (1)
226-226
: Ensure consistency in cache directory path construction.The test
testLocalCacheDirWithSystemProperty
correctly checks if the local cache directory path includes theappId
. However, it's important to ensure that the path construction is consistent across different environments and does not lead to issues with path delimiters on different operating systems.Consider adding a utility method to handle path constructions or ensure that
File.separator
is consistently used across the application to avoid hardcoding path delimiters.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java (4)
Line range hint
52-61
: Initialization of test variables is well-implemented.The setup method correctly initializes
someAppId
andsomeNamespace
, which are crucial for the tests that follow. This ensures that each test can operate with its own set of parameters, enhancing test reliability and isolation.
88-88
: Consistent use of the new constructor across test methods.All instances of
XmlConfigFile
instantiation in the test methods have been updated to include the newappId
parameter. This change is consistent with the modifications described in the PR summary and ensures that the new functionality is being tested correctly.Also applies to: 100-100, 110-110, 126-126, 162-162, 199-199, 235-235
143-143
: Correct adaptation of theonRepositoryChange
method to includeappId
.The
onRepositoryChange
method calls have been correctly updated to include theappId
parameter. This adaptation is crucial for ensuring that the method aligns with the changes made to theXmlConfigFile
class, reflecting the new requirement to handle configurations based on the application ID.Also applies to: 240-240
162-162
: Potential issue with method call intestOnRepositoryChangeWithContentAdded
.The call to
onRepositoryChange
in thetestOnRepositoryChangeWithContentAdded
method does not include theappId
parameter. This seems to be an oversight and could lead to test failures or incorrect behavior since the method signature expects theappId
as the first parameter.Consider updating the method call to include
appId
:- configFile.onRepositoryChange(someNamespace, anotherProperties); + configFile.onRepositoryChange(someAppId, someNamespace, anotherProperties);Likely invalid or redundant comment.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/YamlConfigFileTest.java (7)
42-42
: Setup ofsomeAppId
andsomeNamespace
is correct.The initialization of
someAppId
andsomeNamespace
in thesetUp
method is correctly done. This setup is crucial for the tests that follow, ensuring that theYamlConfigFile
instances are correctly instantiated with these parameters.Also applies to: 55-55
89-89
: Correct instantiation ofYamlConfigFile
.The
YamlConfigFile
is correctly instantiated with the newsomeAppId
parameter along withsomeNamespace
andconfigRepository
. This change aligns with the PR objectives to handle configurations based on application context.
115-115
: Correct instantiation ofYamlConfigFile
with ordered properties.The instantiation of
YamlConfigFile
in thetestWhenHasContentWithOrder
method correctly includes thesomeAppId
parameter. This ensures that the test reflects the new functionality introduced in the PR.
129-129
: Correct instantiation ofYamlConfigFile
in no-content scenario.The instantiation of
YamlConfigFile
in thetestWhenHasNoContent
method correctly includes thesomeAppId
parameter, ensuring that the test accurately tests scenarios where no content is available.
152-152
: Correct instantiation ofYamlConfigFile
in invalid YAML content scenario.The instantiation of
YamlConfigFile
in thetestWhenInvalidYamlContent
method correctly includes thesomeAppId
parameter. This ensures that the test accurately tests scenarios with invalid YAML content.
171-171
: Correct instantiation ofYamlConfigFile
in error scenario.The instantiation of
YamlConfigFile
in thetestWhenConfigRepositoryHasError
method correctly includes thesomeAppId
parameter. This ensures that the test accurately tests scenarios where the config repository encounters an error.
203-203
: Correct handling ofYamlConfigFile
in repository change scenarios.The instantiation and method calls in the
testOnRepositoryChange
andtestWhenConfigRepositoryHasErrorAndThenRecovered
methods correctly include thesomeAppId
parameter. This ensures that the tests accurately reflect the new functionality for handling repository changes based on the application ID.Also applies to: 215-215, 238-238, 245-245
apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/ApolloTestingServer.java (1)
179-179
: Verify the impact of usingsomeAppId
on configuration loading.The introduction of
someAppId
as an argument inLocalFileConfigRepository
is a significant change. It's crucial to verify that this modification does not affect the existing functionality of configuration loading and that it correctly supports the new feature of handling multiple app IDs.Run the following script to verify the impact on configuration loading:
Verification successful
Verified: Usage of
someAppId
inApolloTestingServer.java
The usage of
someAppId
as an argument inLocalFileConfigRepository
is consistent with its role as a placeholder for testing purposes. This change does not impact the configuration loading process in a production environment. The static declaration ofsomeAppId
ensures that it remains a fixed value, aligning with the testing objectives.
ApolloTestingServer.java
:someAppId
is declared and used as a static string.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the impact of using `someAppId` on configuration loading. # Test: Search for the usage of `LocalFileConfigRepository` with `someAppId`. Expect: Correct instantiation and usage. rg --type java -A 5 $'new LocalFileConfigRepository(someAppId, $_)'Length of output: 68
Script:
#!/bin/bash # Description: Search for the declaration and usage of `someAppId` in the codebase. # Find the declaration of `someAppId`. rg --type java 'someAppId' # Find all usages of `someAppId` to understand its context. rg --type java '\bsomeAppId\b'Length of output: 167870
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (6)
68-68
: Refactor: UseTable
forCONFIG_REGISTRY
.The change from a
Map
to aTable
allows for a more structured storage of configurations, associating both an application ID and a namespace with each configuration object. This is a positive change that aligns with the PR's objectives to support multiple app IDs.
94-101
: Update:prepareConfig
method signature and logic.The addition of the
appId
parameter to theprepareConfig
method is consistent with the PR's goal of supporting multiple app IDs. The method now correctly uses theappId
when creating aSimpleConfig
instance and when mocking the config. This change enhances the flexibility and specificity of configuration management within the test framework.
122-130
: Update:prepareYamlConfigFile
method signature and logic.The method now requires an
appId
as an argument, which is used to create and mock aYamlConfigFile
. This change is necessary for the support of multiple app IDs and ensures that configuration files are fetched correctly based on the new key format.
170-171
: Refactor:mockConfig
andmockConfigFile
methods to support multiple app IDs.The methods have been updated to include
appId
in their signatures and logic. This is crucial for correctly storing and retrieving configurations based on both the app ID and namespace, supporting the newTable
structure inCONFIG_REGISTRY
and the modified key format inCONFIG_FILE_REGISTRY
.Also applies to: 178-180
219-220
: Refactor: DefaultappId
handling inMockConfigManager
.The
MockConfigManager
class now defaults to using a specificappId
("someAppId") when only the namespace is provided. This change ensures backward compatibility with existing tests that may not specify anappId
. However, it's important to ensure that this default behavior is clearly documented to avoid confusion.Consider adding documentation or comments in the code to explain the default behavior of using "someAppId" when
appId
is not specified.Also applies to: 233-234
223-228
: Update:getConfig
andgetConfigFile
methods inMockConfigManager
.These methods have been updated to handle the new
appId
parameter, allowing them to retrieve configurations and configuration files based on the new registry structure. The implementation ensures that configurations are fetched correctly based on both the app ID and namespace, which is essential for the new functionality introduced in this PR.Also applies to: 237-238
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java (2)
53-53
: Addition ofsomeAppId
constant.The addition of the
someAppId
constant is a good practice for maintaining consistency across test cases. This ensures that all tests are aligned with the new feature of handling multiple app IDs.
60-61
: UpdatedmockConfig
method calls to includesomeAppId
.The changes to the
mockConfig
method calls across various test methods are consistent with the PR's objective to support multiple app IDs. By addingsomeAppId
as the first parameter, the tests now reflect the updated method signature and are aligned with the new configuration handling capabilities.It's important to ensure that these changes are reflected in the actual implementation of the
mockConfig
method to avoid any runtime errors or misconfigurations. Additionally, the consistency of these changes across different test methods helps maintain uniformity in testing scenarios.Also applies to: 74-74, 84-85, 139-139, 148-148, 158-159
Verification successful
Verification Successful:
mockConfig
Method UpdatedThe
mockConfig
method has been updated to accept three parameters, includingsomeAppId
, as confirmed by its definition inAbstractSpringIntegrationTest.java
. This aligns with the review comment and supports the changes made in the test files to handle multiple app IDs.
- Location of
mockConfig
method definition:
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the `mockConfig` method has been updated to accept three parameters. # Test: Search for the `mockConfig` method definition. Expect: Method definition with three parameters. rg --type java -A 5 $'mockConfig'Length of output: 95736
Script:
#!/bin/bash # Use ast-grep to find the definition of the `mockConfig` method and verify its parameters. ast-grep --lang java --pattern $'void mockConfig($_, $_, $_) { $$$ }'Length of output: 70
Script:
#!/bin/bash # Use rg to search for any method named `mockConfig` to verify its parameters. rg --type java 'void mockConfig' -A 3Length of output: 3955
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (7)
62-62
: Initialization ofsomeAppId
The initialization of
someAppId
with "someAppId" is straightforward and aligns with the PR's objective to handle multiple app IDs. This setup is crucial for the tests that follow, ensuring they operate under the correct application context.
191-204
: Use ofappIdAndNamespace
helper method incheckNamespaceName
The introduction of the
appIdAndNamespace
method suggests a future integration of theappId
into namespace handling. Currently, it returns only the namespace, but this setup indicates potential enhancements. It's important to monitor this method for future changes that might incorporate theappId
more directly into the logic.
84-84
: Modification tocreateConfigRepository
method callThe method
createConfigRepository
now requires anappId
along with thenamespace
. This change is consistent with the PR's goal to support multiple app IDs. It's important to ensure that all calls to this method across the codebase have been updated to pass theappId
as this could break existing functionality if overlooked.Verification successful
Verification Successful: All
createConfigRepository
Calls UpdatedAll instances of the
createConfigRepository
method in the codebase have been updated to include theappId
parameter, ensuring consistency with the updated method signature. No issues were found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `createConfigRepository` include the `appId`. # Test: Search for the method usage. Expect: Only occurrences with two parameters. rg --type java -A 5 $'createConfigRepository'Length of output: 5181
117-117
: Modification tocreatePropertiesCompatibleFileConfigRepository
method callThe method now includes an additional parameter for the
appId
, which is in line with the changes needed to support multiple app IDs. This adjustment is critical and should be checked across the codebase to ensure consistency and avoid runtime errors.Verification successful
Verification Successful: All calls to
createPropertiesCompatibleFileConfigRepository
include theappId
parameter. The codebase is consistent with the changes needed to support multiple app IDs, as described in the review comment. No further action is required.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `createPropertiesCompatibleFileConfigRepository` include the `appId`. # Test: Search for the method usage. Expect: Only occurrences with three parameters. rg --type java -A 5 $'createPropertiesCompatibleFileConfigRepository'Length of output: 2599
136-138
: Repeated modifications tocreateLocalConfigRepository
method callThe method is called multiple times with different namespaces but now includes the
appId
. This repetition confirms the need to handle multiple configurations simultaneously, aligning with the PR's objectives. It's essential to ensure that these changes are reflected wherever this method is used.Verification successful
Consistent usage of
createLocalConfigRepository
method withappId
parameterThe
createLocalConfigRepository
method is consistently used with theappId
parameter across the codebase, including in test files. This confirms that the changes are reflected as intended. No further action is needed.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify repeated calls to `createLocalConfigRepository` include the `appId`. # Test: Search for the method usage. Expect: Multiple occurrences with two parameters. rg --type java -A 5 $'createLocalConfigRepository'Length of output: 6773
216-216
: Modification totrimNamespaceFormat
method callThe method now includes
someAppId
as a parameter, which is necessary for the new functionality to handle multiple app IDs. This change is crucial and should be verified across the project to ensure that it doesn't introduce any regressions.Verification successful
Verification Successful: All calls to
trimNamespaceFormat
includeappId
The method
trimNamespaceFormat
is consistently called with theappId
parameter across the codebase, as required by the recent changes. No regressions are introduced by this modification.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `trimNamespaceFormat` include the `appId`. # Test: Search for the method usage. Expect: Only occurrences with three parameters. rg --type java -A 5 $'trimNamespaceFormat'Length of output: 2363
99-99
: Modification tocreateLocalConfigRepository
method callThis change reflects the addition of
someAppId
to the method signature, which is necessary for the new multi-app ID support. It's crucial to verify that this method's usage throughout the project has been updated accordingly.Verification successful
All usages of
createLocalConfigRepository
have been updated correctly. The method is consistently called with two parameters,appId
andnamespace
, across the codebase, confirming the update for multi-app ID support. No further action is needed.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `createLocalConfigRepository` include the `appId`. # Test: Search for the method usage. Expect: Only occurrences with two parameters. rg --type java -A 5 $'createLocalConfigRepository'Length of output: 6773
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java (3)
109-109
: Enhancement: Support for multiple app IDs.The use of
StringUtils.defaultIfBlank
ensures that a defaultappId
is used if none is specified in the annotation. This change supports the PR's objective to handle multiple app IDs effectively.
111-111
: Correct use of environment placeholders.Resolving placeholders for both
appId
andnamespace
ensures that the configuration can dynamically adapt to different environments, which is crucial for applications that may operate under varying configurations.
113-113
: Update toConfigService.getConfig
call.The method now correctly handles multiple configurations by accepting both
resolvedAppId
andresolvedNamespace
. This change is essential for the flexibility required in multi-application environments.apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/StringUtils.java (1)
343-345
: Review of thedefaultIfBlank
method.The method
defaultIfBlank
is correctly implemented and aligns with the PR's objective to enhance configuration capabilities by allowing a default value for blank strings. The use ofisBlank
to check the string condition is appropriate and leverages existing functionality effectively.
- Correctness: The method correctly checks if the string
s
is blank and returnsappId
if true, otherwise returnss
.- Logic: The logic is straightforward and efficient, using a ternary operator for a concise return statement.
- Performance: The method is efficient as it uses existing logic from
isBlank
and involves minimal computation.- Integration: This method integrates well with the existing utility class and follows the established pattern of utility methods.
Overall, this addition is a valuable enhancement to the
StringUtils
class, providing a useful utility method for handling blank strings in configurations.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (3)
68-69
: Refactor: Simplified constructor delegation.The constructor now delegates to the more general constructor using
null
forappId
. This is a good use of constructor chaining to avoid code duplication.
240-241
: Refactor: Method Overloading foronRepositoryChange
.The method now supports handling changes with an
appId
, which aligns with the new multi-app ID feature. This change ensures that the correct app context is maintained when processing repository changes.
274-274
: Refactor: Calculation of property changes.The method
calcPropertyChanges
is now correctly scoped to handleappId
andnamespace
, which is essential for accurate configuration management in environments with multiple apps. Ensure that this method is robust against potential edge cases where properties might not change but the environment does.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5)
75-75
: Addition ofm_appId
field.The addition of the
m_appId
field is consistent with the PR's objective to handle multiple app IDs. This change allows the class to store the application ID, which is crucial for the new functionality.
160-160
: Update tofireRepositoryChange
method call.The method now includes
m_appId
as an argument, which is necessary for the enhanced functionality of handling multiple app IDs. This change ensures that the application ID is considered when firing repository changes.
191-194
: Use ofm_appId
inloadApolloConfig
method.The method now directly uses
m_appId
instead of callingm_configUtil.getAppId()
. This change is crucial for ensuring that the correct application ID is used in configuration retrieval processes, especially in environments with multiple applications.
336-336
: Modification inscheduleLongPollingRefresh
method.The method now passes
m_appId
along withm_namespace
to theremoteConfigLongPollService.submit
method. This update is essential for maintaining the functionality of long polling in the context of multiple app IDs.
93-97
: Constructor modification to includeappId
.The constructor now requires an
appId
parameter, which is a significant change. This modification aligns with the PR's goal to support multiple app IDs. It's important to ensure that all instantiations of this class across the project are updated to pass theappId
parameter.Verification successful
Constructor usage updated successfully.
All instances of the
RemoteConfigRepository
constructor across the codebase have been updated to include theappId
parameter, as intended. No further action is required.
- Instances found in
RemoteConfigRepositoryTest.java
andDefaultConfigFactory.java
confirm the update.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all constructor calls to `RemoteConfigRepository` match the new signature. # Test: Search for the constructor usage. Expect: Only occurrences of the new signature. rg --type java -A 5 $'new RemoteConfigRepository'Length of output: 8134
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (10)
60-61
: Introduction ofsomeAppId
constant.The addition of the
someAppId
constant is a positive change, promoting better maintainability and readability by centralizing the application ID used in tests. This aligns with the PR's objective to handle multiple app IDs.
96-96
: Proper use ofsomeAppId
in configuration setup.The use of
someAppId
in themockConfig
method call correctly reflects the PR's intent to enhance configuration flexibility by supporting multiple app IDs.
140-141
: Effective use ofsomeAppId
for multiple namespace configurations.The use of
someAppId
for configuring multiple namespaces in the test setup is a clear demonstration of the enhanced flexibility provided by the PR. This is a crucial aspect of supporting multiple app IDs.
176-180
: Consistent use ofsomeAppId
in YAML configuration setup.The introduction of
someAppId
in the preparation of YAML configuration files and its consistent use in configuring multiple namespaces enhances the test's configurability and aligns well with the PR's goals.
218-218
: Correct application ofsomeAppId
in failed conditional test setup.The use of
someAppId
in the configuration setup for a test scenario where the condition fails is appropriate and demonstrates the PR's intent to enhance configurability across different test scenarios.
250-250
: Appropriate use ofsomeAppId
in YAML file preparation for conditional off scenario.The use of
someAppId
to prepare a YAML configuration file for a test scenario with conditions turned off is consistent with the PR's goals and enhances test configurability.
284-284
: Proper application ofsomeAppId
in conditional off test setup.The use of
someAppId
in the configuration setup for a test scenario with conditions turned off is appropriate and demonstrates the PR's intent to enhance configurability across different test scenarios.
414-414
: Effective use ofsomeAppId
in eager load enabled test setup.The use of
someAppId
in the configuration setup for a test scenario with eager load enabled is appropriate and demonstrates the PR's intent to enhance configurability across different test scenarios.
353-353
: Correct application ofsomeAppId
in bootstrap disabled and conditional on test setup.The use of
someAppId
in the configuration setup for a test scenario where bootstrap is disabled and conditions are on is appropriate and demonstrates the PR's intent to enhance configurability across different test scenarios.
382-382
: Proper application ofsomeAppId
in bootstrap disabled and conditional off test setup.The use of
someAppId
in the configuration setup for a test scenario where bootstrap is disabled and conditions are off is appropriate and demonstrates the PR's intent to enhance configurability across different test scenarios.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (2)
78-80
: Review the initialization of ConcurrentHashMap and Maps for tracking long polling and namespaces.The use of
ConcurrentHashMap
form_longPollStarted
andMaps.newConcurrentMap()
form_longPollNamespaces
is appropriate given the need for thread-safe operations in a potentially concurrent environment. This change aligns with the PR's goal to handle multiple app IDs effectively.
299-300
: Review theassembleNamespaces
method adaptation for multi-app support.The method has been adapted to handle multiple app IDs by fetching namespaces specific to an app ID. This change is crucial for ensuring that the long polling URLs are correctly assembled with the appropriate namespaces for each app. The implementation is straightforward and aligns well with the overall enhancements made for multi-app support.
apollo-client/src/test/java/com/ctrip/framework/apollo/integration/ConfigIntegrationTest.java (1)
374-374
: Approved change in timeout duration, suggest verifying test performance impact.The increase in timeout duration from 5000 to 10000 milliseconds in the
longPollFinished.get()
method call is approved as it likely accommodates slower network conditions or server responses. However, it's important to verify that this change does not negatively impact the overall test performance or its effectiveness in catching issues within a reasonable time frame.Run the following script to verify the impact on test performance:
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (1)
272-272
: Verify: Ensure correct parameters inonRepositoryChange
method.The
onRepositoryChange
method is called withsomeAppId
andsomeNamespace
as parameters. Verify that these parameters are correctly used within the method and that the method's implementation aligns with the new requirements for handling multiple app IDs.Also applies to: 321-321
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (2)
457-465
: Review offireConfigChange
method changes:The addition of the
appId
parameter to thefireConfigChange
method aligns with the PR's objectives to support multiple app IDs. The method correctly passes theappId
to theInterestedConfigChangeEvent
.Suggestion:
Ensure that theappId
is correctly integrated and utilized in other parts of the system where this method is called.
Line range hint
570-605
: Review ofcalcPropertyChanges
method changes:The method now includes an
appId
parameter and uses it when creatingConfigChange
objects. This change supports the PR's goal of handling configurations for multiple apps and ensures that changes are associated with the correct app ID.Suggestion:
Verify that theappId
is being used correctly across all instances whereConfigChange
objects are created or processed.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderAutoUpdateTest.java (14)
44-44
: Good practice: Centralizing configuration values.The introduction of the
someAppId
constant is a positive change, enhancing maintainability by avoiding hardcoded values throughout the test cases.
Line range hint
56-68
: Correct usage of the new constant in test scenarios.The method
testAutoUpdateWithOneNamespace
correctly uses thesomeAppId
constant, aligning with the PR's objectives to centralize configuration values. This change enhances the readability and maintainability of the test code.
Line range hint
91-103
: Consistent application of the new constant.The method
testAutoUpdateDisabled
consistently uses thesomeAppId
constant in its configuration setup and repository change calls. This consistency is crucial for maintaining the integrity of the test suite.
123-125
: Effective demonstration of configuration flexibility.The method
testAutoUpdateWithMultipleNamespaces
effectively uses thesomeAppId
constant to demonstrate the new configuration's flexibility across different namespaces. This is a key enhancement in the context of the PR's objectives.
Line range hint
168-181
: Robust testing of complex scenarios.The method
testAutoUpdateWithMultipleNamespacesWithSameProperties
uses thesomeAppId
constant to robustly test the scenario where multiple namespaces are updated with the same properties. This ensures that the new configuration approach can handle complex updates effectively.
Line range hint
198-212
: Proper testing of new properties integration.The method
testAutoUpdateWithNewProperties
correctly uses thesomeAppId
constant to test the integration of new properties. This aligns with the PR's objectives and demonstrates the test's adaptability to configuration changes.
Line range hint
233-247
: Testing robustness against irrelevant property changes.The method
testAutoUpdateWithIrrelevantProperties
effectively uses thesomeAppId
constant to test the system's robustness against irrelevant property changes. This is crucial for ensuring that the configuration system is resilient.
Line range hint
263-274
: Effective handling of property deletions.The method
testAutoUpdateWithDeletedProperties
uses thesomeAppId
constant to effectively test the configuration system's handling of property deletions. This ensures that the system can adapt to changes in configuration without issues.
293-295
: Robust testing of property deletions across multiple namespaces.The method
testAutoUpdateWithMultipleNamespacesWithSamePropertiesDeleted
uses thesomeAppId
constant to robustly test the scenario where properties are deleted across multiple namespaces. This ensures that the new configuration approach can handle complex updates effectively.
Line range hint
323-334
: Testing handling of deletions without default values.The method
testAutoUpdateWithDeletedPropertiesWithNoDefaultValue
uses thesomeAppId
constant to test the configuration system's handling of property deletions without default values. This scenario is important for ensuring robustness in more dynamic configurations.
Line range hint
352-364
: Testing handling of type mismatches in properties.The method
testAutoUpdateWithTypeMismatch
uses thesomeAppId
constant to test the configuration system's handling of type mismatches in properties. This is crucial for ensuring that the system can adapt to incorrect data types without causing failures.
Line range hint
382-394
: Highlighting limitations with constructor-injected values.The method
testAutoUpdateWithValueInjectedAsConstructorArgs
uses thesomeAppId
constant but importantly highlights a limitation of the current system where updates for constructor-injected values are not supported. This is a crucial observation for future enhancements.
Line range hint
413-425
: Effective handling of both value and property updates.The method
testAutoUpdateWithValueAndProperty
uses thesomeAppId
constant to effectively test the configuration system's handling of both value and property updates. This ensures that the system can adapt to changes in configuration without issues.
Line range hint
472-501
: Comprehensive testing of updates across all data types.The method
testAutoUpdateWithAllKindsOfDataTypes
uses thesomeAppId
constant to comprehensively test the configuration system's handling of updates across all data types. This is crucial for ensuring that the system can adapt to diverse configuration needs.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (2)
595-600
: Implementation ofgetAccessKeySecret
inMockConfigUtil
.The new method
getAccessKeySecret
in theMockConfigUtil
class is designed to return a secret based on the providedappId
. This is a critical addition for testing access control based on application identifiers.The implementation checks if the provided
appId
matchessomeAppId
and returnssomeSecret
if true, otherwise returnsnull
. This logic is straightforward and aligns with the requirements for differentiating access based on app IDs. Ensure that this method is covered by unit tests to verify its behavior under different conditions.
149-149
: Updated method signatures in test cases to includesomeAppId
.The method
submit
now correctly includessomeAppId
as part of its signature in all test cases, aligning with the changes in theRemoteConfigLongPollService
class. This is crucial for ensuring that the tests reflect the new functionality of handling multiple app IDs.It's important to verify that all instances where
submit
is called have been updated to passsomeAppId
. Additionally, ensure that the new parameter is being used correctly within the method implementations.Also applies to: 200-200, 262-262, 333-333, 336-336, 404-404, 405-405, 465-465
Verification successful
Verification Successful: Updated method signatures include
someAppId
.The
submit
method inRemoteConfigLongPollService
correctly includessomeAppId
in its signature and uses it appropriately within the method implementation. All instances wheresubmit
is called have been updated to passsomeAppId
, aligning with the changes in theRemoteConfigLongPollService
class.
RemoteConfigLongPollService.java
: Lines 110-126Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `submit` include `someAppId` and check its usage within the method. # Test: Search for the method usage. Expect: Only occurrences with `someAppId`. rg --type java -A 5 $'submit'Length of output: 17743
Script:
#!/bin/bash # Extract the implementation of the `submit` method from `RemoteConfigLongPollService` to verify the usage of `someAppId`. ast-grep --lang java --pattern $'class RemoteConfigLongPollService { $$$ public boolean submit(String appId, String namespace, RemoteConfigRepository remoteConfigRepository) { $$$ } $$$ }'Length of output: 201
Script:
#!/bin/bash # Adjust the pattern to more flexibly capture the `submit` method implementation in `RemoteConfigLongPollService`. ast-grep --lang java --pattern $'public boolean submit(String appId, String namespace, RemoteConfigRepository remoteConfigRepository) { $$$ }'Length of output: 2670
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java (21)
63-63
: Introduction ofsomeAppId
constant.The introduction of the
someAppId
constant is a positive change as it centralizes the application ID, enhancing maintainability and readability. This change aligns with the PR's objective to support multiple app IDs.
74-74
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
82-82
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
95-95
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
111-111
: Refactor to includesomeAppId
inmockConfigFile
.The modification to include
someAppId
as an argument inmockConfigFile
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
127-127
: Refactor to includesomeAppId
inmockConfigFile
.The modification to include
someAppId
as an argument inmockConfigFile
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
139-139
: Refactor to includesomeAppId
inmockConfig
for multiple namespaces.The modification to include
someAppId
as an argument inmockConfig
for bothConfigConsts.NAMESPACE_APPLICATION
andFX_APOLLO_NAMESPACE
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID for multiple namespaces.Also applies to: 143-143
161-161
: Refactor to includesomeAppId
inmockConfigFile
andmockConfig
.The modification to include
someAppId
as an argument in bothmockConfigFile
andmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID for multiple configurations.Also applies to: 165-165
180-180
: Refactor to includesomeAppId
inmockConfig
for multiple namespaces.The modification to include
someAppId
as an argument inmockConfig
for bothConfigConsts.NAMESPACE_APPLICATION
andFX_APOLLO_NAMESPACE
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID for multiple namespaces.Also applies to: 184-184
199-199
: Refactor to includesomeAppId
inmockConfig
for multiple namespaces.The modification to include
someAppId
as an argument inmockConfig
for bothConfigConsts.NAMESPACE_APPLICATION
andFX_APOLLO_NAMESPACE
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID for multiple namespaces.Also applies to: 203-203
217-217
: Refactor to includesomeAppId
inmockConfig
for multiple namespaces.The modification to include
someAppId
as an argument inmockConfig
for bothConfigConsts.NAMESPACE_APPLICATION
andFX_APOLLO_NAMESPACE
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID for multiple namespaces.Also applies to: 221-221
235-235
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
254-254
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
276-276
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
297-297
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
315-315
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
338-338
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
360-360
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
378-378
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
409-409
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.
428-428
: Refactor to includesomeAppId
inmockConfig
.The modification to include
someAppId
as an argument inmockConfig
is consistent with the PR's objectives and enhances the test's clarity by explicitly specifying the app ID.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java (4)
74-74
: Addition ofsomeAppId
variable.The addition of the
someAppId
variable aligns with the PR's objective to handle multiple app IDs. This change is crucial for testing configurations specific to different applications.
95-95
: Initialization ofsomeAppId
andsomeNamespace
.Proper initialization of
someAppId
andsomeNamespace
in thesetUp
method ensures that these variables are correctly set up before each test. This is a necessary change to support the new functionality.
142-142
: File path construction usingsomeAppId
andsomeNamespace
.The construction of file paths using both
someAppId
andsomeNamespace
is a significant change that supports the feature of handling configurations for multiple apps. This approach allows for more granular management of configuration files.
719-719
: Modification inConfigChangeEvent
constructor.The update to include
someAppId
in theConfigChangeEvent
constructor is crucial for tracking configuration changes per app ID. This change supports the PR's goal of enhancing configuration management by allowing more detailed tracking and management of changes.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (19)
81-81
: Introduction ofsomeAppId
variable.The introduction of the
someAppId
static variable is a key part of supporting multiple app IDs. This change aligns with the PR's objectives to enhance configuration capabilities.
116-117
: Correct use ofsomeAppId
in configuration mocking.The method correctly uses the
someAppId
variable to mock configurations, ensuring that the configurations are associated with the correct application ID. This is a crucial part of supporting multiple app IDs.Also applies to: 119-119
135-135
: Consistent use ofsomeAppId
for specific application ID testing.The method correctly uses the
someAppId
variable to mock configurations for testing configurations with a wrong field type, aligning with the PR's objectives.
145-147
: Proper use ofsomeAppId
in inheritance testing.The method correctly uses the
someAppId
variable to mock configurations in a scenario involving inheritance, demonstrating the flexibility and robustness of the new feature.
161-164
: Effective use ofsomeAppId
in expression resolution testing.The method effectively uses the
someAppId
variable to mock configurations for testing the resolution of expressions, aligning with the PR's objectives to enhance configuration capabilities.
Line range hint
176-185
: Accurate use ofsomeAppId
in system property expression resolution testing.The method accurately uses the
someAppId
variable to mock configurations for testing the resolution of expressions from system properties, demonstrating the robustness of the new feature in handling complex scenarios.
197-198
: Proper handling ofsomeAppId
in unresolved value testing.The method properly uses the
someAppId
variable to mock configurations for testing the handling of unresolved values, aligning with the PR's objectives to enhance configuration capabilities.
212-213
: Effective use ofsomeAppId
in configuration change listener testing.The method effectively uses the
someAppId
variable to mock configurations and set up listeners for testing the configuration change listener functionalities, demonstrating the robustness of the new feature in handling dynamic scenarios.
266-266
: Consistent use ofsomeAppId
for specific application ID testing in error scenarios.The method correctly uses the
someAppId
variable to mock configurations for testing configurations with a wrong parameter type, aligning with the PR's objectives.
275-275
: Consistent use ofsomeAppId
for specific application ID testing in error scenarios.The method correctly uses the
someAppId
variable to mock configurations for testing configurations with a wrong parameter count, aligning with the PR's objectives.
285-286
: Proper use ofsomeAppId
in inheritance testing for configuration change listeners.The method correctly uses the
someAppId
variable to mock configurations and set up listeners in a scenario involving inheritance, demonstrating the flexibility and robustness of the new feature.
342-343
: Effective use ofsomeAppId
in configuration change listener testing with interested keys.The method effectively uses the
someAppId
variable to mock configurations and set up listeners for testing the configuration change listener functionalities with interested keys, demonstrating the robustness of the new feature in handling dynamic scenarios.
374-374
: Accurate use ofsomeAppId
in configuration change listener testing with interested key prefixes.The method accurately uses the
someAppId
variable to mock configurations for testing the configuration change listener functionalities with interested key prefixes, aligning with the PR's objectives to enhance configuration capabilities.
400-407
: Effective use ofsomeAppId
in dynamic testing of configuration change listeners with interested key prefixes.The method effectively uses the
someAppId
variable to mock configurations and set up listeners for testing the configuration change listener functionalities with interested key prefixes in a dynamic scenario, demonstrating the robustness of the new feature in handling changes.
Line range hint
439-450
: Accurate use ofsomeAppId
in configuration change listener testing with a YAML file.The method accurately uses the
someAppId
variable to prepare a YAML configuration file and set up listeners for testing the configuration change listener functionalities with a YAML file, aligning with the PR's objectives to enhance configuration capabilities.
464-467
: Effective use ofsomeAppId
in expression resolution testing for configuration change listeners.The method effectively uses the
someAppId
variable to mock configurations for testing the resolution of expressions in configuration change listeners, demonstrating the robustness of the new feature in handling complex scenarios.
502-508
: Effective use ofsomeAppId
in configuration change listener testing with comma-separated namespaces.The method effectively uses the
someAppId
variable to mock configurations for multiple namespaces, demonstrating the robustness of the new feature in handling scenarios involving multiple configurations.
527-533
: Accurate use ofsomeAppId
in configuration change listener testing with comma-separated namespaces merged with ones in value.The method accurately uses the
someAppId
variable to mock configurations for multiple namespaces, aligning with the PR's objectives to enhance configuration capabilities in scenarios involving complex configurations.
548-553
: Accurate use ofsomeAppId
in system property expression resolution testing for configuration change listeners.The method accurately uses the
someAppId
variable to mock configurations for testing the resolution of expressions from system properties in configuration change listeners, aligning with the PR's objectives to enhance configuration capabilities.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderAutoUpdateTest.java (16)
55-55
: Introduction ofsomeAppId
constant.The introduction of the
someAppId
constant is a positive change as it centralizes the application ID, enhancing maintainability and reducing the risk of errors associated with hardcoded strings. This change aligns well with the PR's objective to support multiple app IDs.
74-74
: Consistent use ofsomeAppId
intestAutoUpdateWithOneNamespace
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 129-129
101-101
: Consistent use ofsomeAppId
intestAutoUpdateWithOneYamlFile
.The method correctly uses the
someAppId
constant in theprepareYamlConfigFile
call, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 161-161
129-129
: Consistent use ofsomeAppId
intestAutoUpdateWithValueAndXmlProperty
.The method correctly uses the
someAppId
constant in theprepareConfig
call, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 199-199
229-229
: Consistent use ofsomeAppId
intestAutoUpdateWithMultipleNamespaces
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 241-241
270-270
: Consistent use ofsomeAppId
intestAutoUpdateWithMultipleNamespacesWithSameProperties
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 283-283
298-298
: Consistent use ofsomeAppId
intestAutoUpdateWithMultipleNamespacesWithSamePropertiesWithYamlFile
.The method correctly uses the
someAppId
constant in bothprepareYamlConfigFile
andprepareConfig
calls, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 303-303
328-328
: Consistent use ofsomeAppId
intestAutoUpdateWithNewProperties
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 340-340
354-354
: Consistent use ofsomeAppId
intestAutoUpdateWithNewPropertiesWithYamlFile
.The method correctly uses the
someAppId
constant in theprepareYamlConfigFile
call, aligning with the PR's objectives and enhancing code maintainability.
385-385
: Consistent use ofsomeAppId
intestAutoUpdateWithIrrelevantProperties
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 397-397
413-413
: Consistent use ofsomeAppId
intestAutoUpdateWithDeletedProperties
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 424-424
437-437
: Consistent use ofsomeAppId
intestAutoUpdateWithDeletedPropertiesWithYamlFile
.The method correctly uses the
someAppId
constant in theprepareYamlConfigFile
call, aligning with the PR's objectives and enhancing code maintainability.Also applies to: 447-447
465-465
: Consistent use ofsomeAppId
intestAutoUpdateWithMultipleNamespacesWithSamePropertiesDeleted
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.
494-494
: Consistent use ofsomeAppId
intestAutoUpdateWithDeletedPropertiesWithNoDefaultValue
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.
523-523
: Consistent use ofsomeAppId
intestAutoUpdateWithTypeMismatch
.The method correctly uses the
someAppId
constant in bothprepareConfig
andonRepositoryChange
calls, aligning with the PR's objectives and enhancing code maintainability.
549-549
: Consistent use ofsomeAppId
intestAutoUpdateWithTypeMismatchWithYamlFile
.The method correctly uses the
someAppId
constant in theprepareYamlConfigFile
call, aligning with the PR's objectives and enhancing code maintainability.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactoryManager.java
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/TxtConfigFileTest.java
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
...lo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
Show resolved
Hide resolved
...lo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
Show resolved
Hide resolved
...lo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
Show resolved
Hide resolved
...ient/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
Outdated
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
Outdated
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
...ient/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (3)
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (3)
106-126
: Optimize Iteration OverAPP_NAMESPACE_NAMES
In the
initializePropertySources
method, the nested loops overorders
,appIds
, andnamespaces
could be optimized for readability and performance.Consider simplifying the iteration:
for (Map.Entry<Integer, Multimap<String, String>> entry : APP_NAMESPACE_NAMES.entrySet()) { int order = entry.getKey(); Multimap<String, String> appMultimap = entry.getValue(); for (Map.Entry<String, String> appNamespaceEntry : appMultimap.entries()) { String appId = appNamespaceEntry.getKey(); String namespace = appNamespaceEntry.getValue(); Config config = ConfigService.getConfig(appId, namespace); composite.addPropertySource(configPropertySourceFactory.getConfigPropertySource( appId + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + namespace, config)); } }This approach reduces the number of iterations and may improve performance.
178-178
: Consistent Clearing of Static Collections inreset
MethodEnsure that the
reset
method clears all relevant static collections to avoid unintended state retention during tests.Consider confirming that all static collections are cleared:
public static void reset() { APP_NAMESPACE_NAMES.clear(); AUTO_UPDATE_INITIALIZED_BEAN_FACTORIES.clear(); + // Any other static collections should be cleared here }
This helps maintain a clean state between test runs.
Line range hint
23-50
: Remove Unused ImportsThere are several unused import statements which can be removed to clean up the code.
Consider removing the following unused imports:
import java.util.HashMap;
(line 35)import org.springframework.util.CollectionUtils;
(line 50)This helps in maintaining code cleanliness.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (6 hunks)
🔇 Additional comments (1)
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (1)
126-126
: Verify Safe Clearing ofAPP_NAMESPACE_NAMES
Clearing
APP_NAMESPACE_NAMES
after initialization might lead to issues ifaddNamespaces
is called afterward. Ensure thataddNamespaces
is not intended to be used post-initialization.Run the following script to check for any calls to
addNamespaces
afterinitializePropertySources
:✅ Verification successful
Safe Clearing of
APP_NAMESPACE_NAMES
ConfirmedNo invocations of
addNamespaces
were found afterinitializePropertySources
, ensuring that clearingAPP_NAMESPACE_NAMES
does not lead to unintended namespace additions post-initialization.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find calls to addNamespaces after initializePropertySources. # Expected Result: No calls to addNamespaces after initializePropertySources. rg --type java -A 5 -B 5 "initializePropertySources" | awk '/initializePropertySources/,0' | rg "addNamespaces"Length of output: 107
Script:
#!/bin/bash # Description: Search for invocations of addNamespaces within 10 lines after initializePropertySources in Java files. # Expected Result: No invocations of addNamespaces after initializePropertySources. rg --type java "initializePropertySources" -A 10 | rg "addNamespaces"Length of output: 67
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your hard work on the pull request; I believe it's nearing approval. Please see my comments below.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
Outdated
Show resolved
Hide resolved
...-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java
Outdated
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
if(repositoryMultimap == null){ | ||
repositoryMultimap = Multimaps.synchronizedSetMultimap(HashMultimap.<String, RemoteConfigRepository>create()); | ||
m_longPollNamespaces.put(appId, repositoryMultimap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to consider a race condition here. For example, two threads submitting different namespaces with the same appid.
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
Show resolved
Hide resolved
...ient/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
Outdated
Show resolved
Hide resolved
...ient/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
Outdated
Show resolved
Hide resolved
...lo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
Outdated
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
I noticed the CLA check failed again, and it seems the original commits are back. Is there some mistaken operation on the branch? |
5280fcd
to
83bf929
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 30
🧹 Outside diff range and nitpick comments (61)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/XmlConfigFile.java (1)
25-27
: LGTM! Consider adding Javadoc for the new parameter.The addition of the
appId
parameter to the constructor is well-implemented and aligns with the PR objective of supporting multiple app IDs. The change is correct and follows good practices.Consider adding Javadoc to document the new
appId
parameter:+/** + * Constructs a new XmlConfigFile. + * + * @param appId The ID of the application + * @param namespace The namespace for the configuration + * @param configRepository The configuration repository + */ public XmlConfigFile(String appId, String namespace, ConfigRepository configRepository) { super(appId, namespace, configRepository); }apollo-client/src/main/java/com/ctrip/framework/apollo/internals/JsonConfigFile.java (1)
25-27
: LGTM! Consider adding a brief Javadoc comment.The constructor change looks good and aligns with the PR objective of adding support for multiple app IDs. The implementation is correct and consistent.
Consider adding a brief Javadoc comment to explain the purpose of the
appId
parameter:/** * Constructs a new JsonConfigFile. * * @param appId The ID of the application this config file belongs to * @param namespace The namespace of the config file * @param configRepository The repository to fetch configurations from */ public JsonConfigFile(String appId, String namespace, ConfigRepository configRepository) { super(appId, namespace, configRepository); }apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java (1)
32-38
: LGTM! The new method signature enhances functionality while maintaining backward compatibility.The addition of the
onRepositoryChange(String appId, String namespace, Properties newProperties)
method aligns well with the PR objectives of supporting multiple app IDs. This change allows for more granular control over repository changes by including theappId
parameter.Consider adding a brief explanation in the Javadoc about when this new method would be called instead of the existing one. This could help implementers understand the use cases for each method. For example:
/** * Invoked when config repository changes for a specific app ID. * This method is called when the change is associated with a particular application. * @param appId the appId of this repository change * @param namespace the namespace of this repository change * @param newProperties the properties after change */apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigRegistry.java (1)
50-57
: LGTM: New getFactory method with appId parameter.The new
getFactory
method withappId
parameter is well-implemented and documented. It aligns with the PR objectives of supporting multiple app IDs and extends the existing functionality in a consistent manner.Consider adding a
@since
tag to the Javadoc to indicate the version in which this method was introduced. This can help users understand when this functionality became available. For example:/** * Get the registered config factory for the namespace. * * @param appId the appId * @param namespace the namespace * @return the factory registered for this appId and namespace * @since 2.4.0 */ ConfigFactory getFactory(String appId, String namespace);apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactory.java (1)
51-57
: Approve with minor documentation update needed.The addition of this method aligns well with the PR objective of supporting multiple app IDs. The method signature is consistent with the existing interface. However, the Javadoc comment needs to be updated to include information about the
configFileFormat
parameter.Please update the Javadoc comment to include all parameters:
/** * Create the config file instance for the appId and namespace. * @param appId the appId * @param namespace the namespace * @param configFileFormat the format of the config file * @return the newly created config file instance */apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (2)
52-57
: Approved with a minor suggestion for the JavaDoc.The new
appId
parameter is well-implemented and aligns with the PR objectives. It provides the desired functionality for supporting multiple app IDs while maintaining backward compatibility with the default empty string.Consider slightly rewording the JavaDoc for clarity:
/** - * Apollo appId for the config, if not specified then default to the global appid + * Apollo appId for the config. If not specified, defaults to the global appId. * * @since 2.4.0 */
Line range hint
20-38
: Enhance class-level JavaDoc to explain the relationship betweenappId
andvalue
.The addition of the
appId
parameter alongside the existingvalue
parameter provides powerful configuration capabilities. To help users understand how to use these parameters together effectively, consider updating the class-level JavaDoc.Add an explanation of how
appId
andvalue
work together in the class-level JavaDoc. For example:/** * Use this annotation to inject Apollo Config Instance. * * <p>Usage example:</p> * <pre class="code"> * //Inject the config for "someNamespace" * @ApolloConfig("someNamespace") * private Config config; * </pre> * * <p>Usage example with placeholder:</p> * <pre class="code"> * // The namespace could also be specified as a placeholder, e.g. ${redis.namespace:xxx}, * // which will use the value of the key "redis.namespace" or "xxx" if this key is not configured. * @ApolloConfig("${redis.namespace:xxx}") * private Config config; * </pre> * * <p>Usage example with appId:</p> * <pre class="code"> * // Inject the config for a specific appId and namespace * @ApolloConfig(appId = "someAppId", value = "someNamespace") * private Config config; * </pre> * * <p>The `appId` parameter allows you to specify a different Apollo application ID for this particular config. * If not provided, it defaults to the global appId. The `value` parameter specifies the namespace within the * chosen application. This combination enables fine-grained control over configuration sources.</p> * * @author Jason Song([email protected]) */This addition will help users understand how to leverage both parameters effectively.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/TxtConfigFileTest.java (1)
54-57
: LGTM: UpdatedTxtConfigFile
instantiation andappId
assertionThe changes in the
testWhenHasContent
method correctly incorporate the newappId
functionality:
- The
TxtConfigFile
constructor now includessomeAppId
as a parameter.- A new assertion verifies that the
appId
is correctly set in theTxtConfigFile
.These changes are consistent with the PR objective and improve the test coverage.
As suggested in a previous review, consider adding more comprehensive tests to cover various scenarios and edge cases involving
appId
. This will ensure robust coverage of the new functionality. Would you like assistance in drafting additional test cases?apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (1)
34-40
: Approve with suggestions for improvementThe addition of this method aligns well with the PR objectives to support multiple app IDs. However, there are a couple of minor improvements we can make:
- The method documentation can be enhanced for clarity. Consider using the following format:
/** * Get the config instance for the namespace and appId specified. * @param appId the appId * @param namespace the namespace * @return the config instance for the appId and namespace */
- There's a minor spacing inconsistency in the method signature. Add a space after the comma for better readability:
Config getConfig(String appId, String namespace);apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (1)
78-84
: ThegetAppId()
method is correctly implemented.The new method is well-structured and consistent with the class design. However, there's a minor improvement that can be made to the JavaDoc comment.
Consider updating the JavaDoc comment to accurately reflect the method's purpose:
/** - * Get the appId of this change event. - * @return the namespace + * Get the appId associated with this change event. + * @return the appId */ public String getAppId() { return m_appId; }apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java (2)
66-69
: LGTM! Consider adding a comment for clarity.The addition of this method aligns with the PR objective of supporting multiple app IDs. The implementation is correct for a mock object in a test class.
Consider adding a comment to explain why this method returns null, for example:
@Override public Config create(String appId, String namespace) { + // Return null for mock implementation return null; }
76-79
: LGTM! Consider adding a comment for clarity.The addition of this method aligns with the PR objective of supporting multiple app IDs. The implementation is correct for a mock object in a test class.
Consider adding a comment to explain why this method returns null, for example:
@Override public ConfigFile createConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat) { + // Return null for mock implementation return null; }
apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (1)
Line range hint
89-99
: Consider updating thetoString()
methodThe
toString()
method has not been updated to include the newappId
field. Consider adding it to provide a complete string representation of the object.Here's a suggested update:
@Override public String toString() { final StringBuilder sb = new StringBuilder("ConfigChange{"); + sb.append("appId='").append(appId).append('\''); + sb.append(", "); sb.append("namespace='").append(namespace).append('\''); sb.append(", propertyName='").append(propertyName).append('\''); sb.append(", oldValue='").append(oldValue).append('\''); sb.append(", newValue='").append(newValue).append('\''); sb.append(", changeType=").append(changeType); sb.append('}'); return sb.toString(); }apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (2)
Line range hint
1-91
: Summary: Good progress on multi-app support, consider broader impactThe changes to
PureApolloConfig.java
are minimal but significant, adding support for multiple app IDs as required. However, to ensure full implementation of multi-app support, consider reviewing and potentially updating related classes, especially the superclassDefaultConfig
and any other classes that interact with app IDs.It might be beneficial to conduct a broader review of the entire module to ensure consistent handling of multiple app IDs across all relevant classes and methods.
AppId handling missing in superclass methods
The
getProperty
andgetPropertyNames
methods inAbstractConfig
do not handle theappId
parameter. This may affect proper multi-app support. Please update these methods to utilizeappId
appropriately.🔗 Analysis chain
Line range hint
54-91
: Verify handling ofappId
in superclass methodsThe
getProperty
andgetPropertyNames
methods remain unchanged and don't directly use theappId
parameter. To ensure proper multi-app support, we should verify that these methods (or their superclass implementations) correctly utilize theappId
when retrieving properties.Please run the following script to check the implementation of these methods in the
DefaultConfig
class:If these methods in
DefaultConfig
don't handle theappId
, consider updating them to ensure proper multi-app support.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check the implementation of getProperty and getPropertyNames in DefaultConfig # Test: Search for getProperty and getPropertyNames methods in DefaultConfig ast-grep --lang java --pattern $'class DefaultConfig { $$$ getProperty($$$) { $$$ } $$$ getPropertyNames($$$) { $$$ } $$$ }'Length of output: 147
Script:
#!/bin/bash # Description: Verify the existence of DefaultConfig class and its methods # Check if DefaultConfig.java exists in the codebase rg --files --type java 'DefaultConfig\.java' # If DefaultConfig.java is found, search for getProperty and getPropertyNames methods within it rg 'public\s+String\s+getProperty\s*\(.*\)' DefaultConfig.java rg 'public\s+Set<\s*String\s*>\s+getPropertyNames\s*\(.*\)' DefaultConfig.java # If methods are not found in DefaultConfig, search in its superclass # First, identify the superclass of DefaultConfig SUPERCLASS=$(rg 'public\s+class\s+DefaultConfig\s+extends\s+(\w+)' DefaultConfig.java -o | awk '{print $4}') # If a superclass is identified, search for the methods in the superclass if [ -n "$SUPERCLASS" ]; then SUPERCLASS_FILE=$(rg --files --type java "${SUPERCLASS}\.java") if [ -n "$SUPERCLASS_FILE" ]; then rg 'public\s+String\s+getProperty\s*\(.*\)' "$SUPERCLASS_FILE" rg 'public\s+Set<\s*String\s*>\s+getPropertyNames\s*\(.*\)' "$SUPERCLASS_FILE" else echo "Superclass file for $SUPERCLASS not found." fi else echo "No superclass found for DefaultConfig." fiLength of output: 645
Script:
#!/bin/bash # Description: Locate DefaultConfig class and its methods across the codebase # Search for the class definition of DefaultConfig in all Java files rg 'public\s+class\s+DefaultConfig\b' --type java --context 2 # If DefaultConfig class is found, extract the file paths DEFAULT_CONFIG_FILES=$(rg 'public\s+class\s+DefaultConfig\b' --type java --files-with-matches) # If DefaultConfig.java files are found, search for the specified methods within them if [ -n "$DEFAULT_CONFIG_FILES" ]; then for file in $DEFAULT_CONFIG_FILES; do echo "Searching in $file:" rg 'public\s+String\s+getProperty\s*\(.*\)' "$file" rg 'public\s+Set<\s*String\s*>\s+getPropertyNames\s*\(.*\)' "$file" done else echo "No class named DefaultConfig found in any Java files." fiLength of output: 1609
Script:
#!/bin/bash # Description: Locate AbstractConfig class and verify handling of appId in its methods # Search for the class definition of AbstractConfig in all Java files rg 'public\s+abstract\s+class\s+AbstractConfig\b' --type java --context 2 # Extract the file paths containing AbstractConfig class ABSTRACT_CONFIG_FILES=$(rg 'public\s+abstract\s+class\s+AbstractConfig\b' --type java --files-with-matches) # If AbstractConfig class is found, search for getProperty and getPropertyNames methods within it if [ -n "$ABSTRACT_CONFIG_FILES" ]; then for file in $ABSTRACT_CONFIG_FILES; do echo "Inspecting $file:" # Extract the getProperty method rg -C 5 'public\s+String\s+getProperty\s*\(.*\)' "$file" # Extract the getPropertyNames method rg -C 5 'public\s+Set<\s*String\s*>\s+getPropertyNames\s*\(.*\)' "$file" # Search for usage of appId within getProperty method echo "Checking getProperty method for appId handling:" rg 'getProperty\s*\(.*appId.*\)' "$file" # Search for usage of appId within getPropertyNames method echo "Checking getPropertyNames method for appId handling:" rg 'getPropertyNames\s*\(.*appId.*\)' "$file" done else echo "No class named AbstractConfig found in any Java files." fiLength of output: 1974
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryFileCachePropertyTest.java (2)
58-59
: LGTM: Updated method calls and verificationsThe changes correctly reflect the updated method signatures in
DefaultConfigFactory
, now including bothappId
andnamespace
parameters. The test logic is maintained while accommodating the new parameter.Consider extracting the
someAppId
andsomeNamespace
arguments into variables at the beginning of the test method for improved readability and easier maintenance. For example:@Test public void testCreateFileEnableConfigRepository() throws Exception { String testAppId = someAppId; String testNamespace = someNamespace; LocalFileConfigRepository someLocalConfigRepository = mock(LocalFileConfigRepository.class); when(someConfigUtil.isPropertyFileCacheEnabled()).thenReturn(true); doReturn(someLocalConfigRepository).when(configFactory) .createLocalConfigRepository(testAppId, testNamespace); ConfigRepository configRepository = configFactory.createConfigRepository(testAppId, testNamespace); assertSame(someLocalConfigRepository, configRepository); verify(configFactory, times(1)).createLocalConfigRepository(testAppId, testNamespace); verify(configFactory, never()).createRemoteConfigRepository(testAppId, testNamespace); }This approach would make it easier to use different test values if needed in the future.
Also applies to: 61-62
70-71
: LGTM: Updated method calls and verificationsThe changes correctly reflect the updated method signatures in
DefaultConfigFactory
, now including bothappId
andnamespace
parameters. The test logic is maintained while accommodating the new parameter, and the changes are consistent with those made in thetestCreateFileEnableConfigRepository
method.As suggested for the
testCreateFileEnableConfigRepository
method, consider extracting thesomeAppId
andsomeNamespace
arguments into variables at the beginning of this test method as well. This would improve readability and make it easier to use different test values if needed in the future.Also applies to: 73-74
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java (2)
45-46
: LGTM with a minor suggestion.The addition of
someAppId
aligns with the PR objective of supporting multiple app IDs. However, consider using a more realistic app ID value or making it clear that this is a test value.You could improve this by using a more descriptive name like
TEST_APP_ID
and potentially adding a comment explaining its purpose in the test:private static final String TEST_APP_ID = "test-app-id"; // This represents a sample app ID used for testing multiple app ID support
Line range hint
45-77
: Overall LGTM with a suggestion for improved test coverage.The changes in this file consistently implement support for multiple app IDs, aligning well with the PR objective. The test logic remains intact while incorporating the new app ID parameter.
To further improve the test coverage:
Consider adding a test case that verifies the behavior with multiple different app IDs to ensure the system correctly handles distinct configurations for different applications. This could involve creating multiple
ConfigChange
objects with different app IDs and verifying that they are processed correctly.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java (1)
Line range hint
138-151
: LGTM with a minor suggestion: Updates intestOnRepositoryChange
The changes in this method are well-implemented and consistent with the PR objective:
- The
SimpleConfig
constructor call now includessomeAppId
.- The
onRepositoryChange
method call has been updated to includesomeAppId
.- A new assertion verifies that the
changeEvent
contains the correctappId
.These updates ensure that the test case properly handles and verifies the new app ID functionality.
Consider adding a constant for the "someAppId" string to improve maintainability:
private static final String SOME_APP_ID = "someAppId";Then use
SOME_APP_ID
instead of the string literal throughout the test class.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java (1)
Line range hint
1-194
: Summary of changes and suggestions for next stepsThe changes in this file consistently introduce and use the
someAppId
variable across multiple test methods, which aligns well with the PR objective of adding support for multiple app IDs. This improves the maintainability and consistency of the test code.Suggestions for next steps:
- Verify the
fireConfigChange
method signature change across the codebase using the provided script.- Consider adding assertions for the new
fireConfigChange
method call in thetestFireConfigChange_cannot_notify
method.- Update the class-level or file-level documentation to mention the support for multiple app IDs, if not already done in other files.
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (2)
58-59
: LGTM: Setting APP_ID system propertySetting the
APP_ID
system property in thesetUp
method ensures consistency across all tests. This change aligns well with the PR objective of supporting multiple app IDs.Consider adding a
tearDown
step to clear this system property after tests, ensuring a clean state for other test classes:@After public void tearDown() throws Exception { System.clearProperty(ApolloClientSystemConsts.APP_ID); // ... other tearDown operations }
81-87
: LGTM: Updated test to incorporate app ID in configurations and assertionsThe changes in the
testInitializePropertySources
method correctly integrate thesomeAppId
into the configuration mocking and property source name assertions. This ensures that the tests accurately reflect the new multi-app ID support.For improved readability, consider extracting the expected property source name construction into a separate method:
private String getExpectedPropertySourceName(String appId, String namespace) { return appId + ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR + namespace; }Then use it in the assertions:
assertEquals(getExpectedPropertySourceName(someAppId, namespaceName), propertySource.getName()); assertEquals(getExpectedPropertySourceName(someAppId, anotherNamespaceName), anotherPropertySource.getName());This would make the test more maintainable if the naming convention changes in the future.
Also applies to: 105-107
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java (5)
122-122
: LGTM! Consider adding an assertion forappId
.The change correctly updates the
LocalFileConfigRepository
constructor to include thesomeAppId
parameter. This aligns with the new signature mentioned in the summary.Consider adding an assertion to verify that the
appId
is correctly set in theLocalFileConfigRepository
instance. This would enhance the test coverage for the new parameter.
138-138
: LGTM! Consider testingappId
influence.The change correctly updates the
LocalFileConfigRepository
constructor to include thesomeAppId
parameter. This aligns with the new signature mentioned in the summary.Consider adding a test case that verifies how different
appId
values affect the behavior ofLocalFileConfigRepository
. This would ensure that the new parameter is correctly influencing the repository's functionality.
164-165
: LGTM! Consider testing with differentappId
values.The changes correctly update both
LocalFileConfigRepository
constructor calls to include thesomeAppId
parameter. This aligns with the new signature mentioned in the summary.Consider adding a test case that uses different
appId
values for the twoLocalFileConfigRepository
instances. This would verify that theappId
parameter correctly influences the behavior when loading configurations multiple times.Also applies to: 171-171
187-188
: LGTM! Consider additional assertions forappId
handling.The changes correctly update the
LocalFileConfigRepository
constructor andonRepositoryChange
method calls to include thesomeAppId
parameter. The verification of the listener has also been updated accordingly. These changes align with the new signatures mentioned in the summary.Consider adding assertions to verify that the
appId
is correctly propagated through the repository change event. For example, you could check that theProperties
object passed to the listener contains anyappId
-specific configurations.Also applies to: 204-204, 208-208
Line range hint
1-238
: Overall LGTM! Consider enhancing tests forappId
functionality.The changes in this file consistently update the
LocalFileConfigRepository
constructor calls and relevant method invocations to include the newappId
parameter. This aligns well with the goal of supporting multiple app IDs as mentioned in the PR objectives.To further improve the test coverage and ensure the robustness of the new multi-app ID feature:
- Consider adding test cases that use different
appId
values to verify that configurations are correctly isolated between different apps.- Add assertions to check that the
appId
is correctly propagated through various operations (loading, updating, repository change events).- Test edge cases, such as empty or null
appId
values, to ensure proper error handling.- Consider adding a test that verifies the behavior when switching between different
appId
values within the sameLocalFileConfigRepository
instance, if applicable.These enhancements would provide more comprehensive coverage of the new functionality and help catch any potential issues related to the multi-app ID support.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java (1)
Line range hint
1-244
: Consider adding tests for app ID-specific scenariosWhile the changes to include
someAppId
are consistent across all test methods, consider adding new test cases that specifically verify the behavior ofXmlConfigFile
with different app IDs. This could help ensure that the multi-app ID support is thoroughly tested.apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/ApolloTestingServer.java (2)
179-179
: Approve change with suggestion for improvementThe modification to use
someAppId
inLocalFileConfigRepository
initialization is a step towards supporting multiple app IDs, which aligns with the PR objectives. However, to fully leverage this change and provide maximum flexibility, consider the following improvement:public Properties loadPropertiesOfNamespace(String appId, String namespace) { String filename = String.format("mockdata-%s-%s.properties", appId, namespace); // ... (existing code for checking mockdata properties) return new LocalFileConfigRepository(appId, namespace).getConfig(); }This approach would allow testing with different app IDs without modifying the
someAppId
static variable, providing more flexibility in mock scenarios.
Line range hint
1-248
: Summary of changes and suggestions for improvementThe modifications to
ApolloTestingServer.java
introduce support for app ID in the mock server, which aligns with the PR objectives. However, the current implementation using a staticsomeAppId
limits the flexibility intended by this change.To fully realize the goal of supporting multiple app IDs and enhance the mock server's capabilities:
- Make
someAppId
configurable as suggested in the first comment.- Modify methods like
loadPropertiesOfNamespace
to accept an app ID parameter, allowing for dynamic app ID usage in tests.- Update other relevant methods in this class to support multiple app IDs where applicable.
These enhancements would provide a more robust and flexible mock server implementation, better serving the needs of various testing scenarios.
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (6)
84-86
: LGTM with suggestion: Update totestCreate
methodThe changes correctly reflect the updated method signatures to include the
someAppId
parameter. This is in line with the PR objective of supporting multiple app IDs.Consider adding an assertion to verify that the created config is associated with the correct app ID. This could be done by exposing the app ID in the
DefaultConfig
class and asserting it in the test.
99-99
: LGTM with suggestion: Update totestCreateLocalConfigRepositoryInLocalDev
methodThe change correctly reflects the updated method signature to include the
someAppId
parameter, which is in line with the PR objective.Consider adding an assertion to verify that the created
LocalFileConfigRepository
is associated with the correct app ID. This could be done by exposing the app ID in theLocalFileConfigRepository
class and asserting it in the test.
117-119
: LGTM with suggestion: Update totestCreatePropertiesCompatibleFileConfigRepository
methodThe changes correctly reflect the updated method signatures to include the
someAppId
parameter, which is consistent with the PR objective of supporting multiple app IDs.Consider adding an assertion to verify that the created config is associated with the correct app ID. This could be done by exposing the app ID in the
DefaultConfig
class and asserting it in the test.
136-138
: LGTM with suggestion: Update totestCreateConfigFile
methodThe changes correctly reflect the updated method signatures to include the
someAppId
parameter forcreateLocalConfigRepository
calls. This is in line with the PR objective of supporting multiple app IDs.Consider adding assertions to verify that the created config files are associated with the correct app ID. This could be done by exposing the app ID in the respective config file classes (e.g.,
PropertiesConfigFile
,XmlConfigFile
, etc.) and asserting it in the test for each created config file.
206-208
: Suggestion: Add TODO comment forappIdAndNamespace
methodThe
appIdAndNamespace
method has been introduced, but it currently just returns the namespace unchanged. This appears to be a placeholder for future functionality.Consider adding a TODO comment to explain the intended future use of this method. For example:
private String appIdAndNamespace(String namespace){ + // TODO: Implement logic to combine appId and namespace for multi-app support return namespace; }
Line range hint
1-231
: Overall assessment: Changes align with PR objective, with room for improvementThe changes in this file consistently add support for the
someAppId
parameter across various test methods, which aligns well with the PR objective of adding support for multiple app IDs.However, there are a few areas where the test coverage and clarity could be improved:
- Consider adding assertions to verify that the created configs and repositories are associated with the correct app ID in various test methods.
- Clarify the purpose and future plans for the
appIdAndNamespace
method and its usage intestTrimNamespaceFormat
.- Ensure that the changes in this test class accurately reflect the changes made in the main
DefaultConfigFactory
class.As you continue to implement multi-app ID support, consider the following:
- Ensure consistent handling of app IDs across all relevant classes in the Apollo client.
- Update documentation to reflect the new multi-app ID functionality.
- Consider adding integration tests that verify the correct behavior when multiple app IDs are used in a real-world scenario.
These improvements will help ensure that the new functionality is robust and well-tested.
apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/StringUtils.java (1)
343-345
: Approve with suggestions for improvementThe
defaultIfBlank
method is a good addition to theStringUtils
class. It provides a useful utility for handling potentially blank strings with a default value. However, there are a few suggestions for improvement:
Consider adding a null check for
appId
to prevent potential NullPointerExceptions. This could be done by using the existingdefaultIfBlank
method in a nested manner.Add method documentation (Javadoc) to explain the purpose, parameters, and return value of the method.
Use a more descriptive name for the
s
parameter, such asstr
orinput
.Here's a suggested implementation with these improvements:
/** * Returns the input string if it is not blank, otherwise returns the default appId. * If both the input string and appId are blank or null, returns null. * * @param input the input string to check * @param appId the default appId to return if the input is blank * @return the input string if not blank, the appId if input is blank, or null if both are blank or null */ public static String defaultIfBlank(String input, String appId) { return isBlank(input) ? (isBlank(appId) ? null : appId) : input; }This implementation handles the case where both
input
andappId
might be null or blank, returning null in such cases. It also uses more descriptive parameter names and includes documentation.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (1)
Line range hint
1-468
: Overall assessment: Consistent and well-structured changesThe modifications in this file demonstrate a systematic approach to introducing support for multiple app IDs in the Apollo Client test suite. Key observations:
- The
someAppId
constant has been consistently added to various method calls across different test scenarios, ensuring comprehensive coverage of the new functionality.- The changes maintain consistency across different test classes and scenarios, including those with YAML configurations and various bootstrap settings.
- Some method signatures have been updated to include exception handling, potentially improving robustness in error scenarios.
These changes appear to be part of a larger refactoring effort to enhance the Apollo Client's capabilities. The consistency and thoroughness of the modifications are commendable, suggesting a well-planned implementation of the new feature.
As this change introduces support for multiple app IDs, ensure that:
- The documentation is updated to reflect this new capability.
- Any client-side code that interacts with the Apollo Client is reviewed for potential impacts.
- Performance implications of supporting multiple app IDs are considered and tested, especially in scenarios with a large number of app IDs.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (2)
151-151
: LGTM: Updated RemoteConfigRepository constructor calls.The RemoteConfigRepository constructor calls have been consistently updated across all test methods to include the
someAppId
parameter. This change aligns with the modification of the RemoteConfigRepository constructor to accept an additionalappId
parameter.Consider refactoring the creation of RemoteConfigRepository instances into a helper method to reduce code duplication:
private RemoteConfigRepository createRemoteConfigRepository() { return new RemoteConfigRepository(someAppId, someNamespace); }Then replace all instances of
new RemoteConfigRepository(someAppId, someNamespace)
withcreateRemoteConfigRepository()
.Also applies to: 177-177, 214-214, 227-227, 240-240, 257-257, 293-293, 345-345
423-429
: LGTM with suggestion: New getAccessKeySecret method.The addition of the
getAccessKeySecret(String appId)
method in MockConfigUtil is consistent with the multi-app ID support. The implementation correctly returnssomeSecret
for the matchingappId
.Consider throwing an IllegalArgumentException for unrecognized app IDs instead of returning null. This would make the behavior more explicit and help prevent potential NullPointerExceptions:
@Override public String getAccessKeySecret(String appId) { if (appId.equals(someAppId)) { return someSecret; } throw new IllegalArgumentException("Unrecognized appId: " + appId); }This change would require updating the tests to expect this exception for invalid app IDs, which could improve the robustness of your test suite.
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (3)
311-320
: LGTM! Consider adding parameter validation.The new
getDefaultLocalCacheDir(String appId)
method correctly implements the functionality to determine the cache directory based on the providedappId
. It reuses existing logic and is consistent with the current implementation.Consider adding a null check for the
appId
parameter at the beginning of the method:public String getDefaultLocalCacheDir(String appId) { + if (Strings.isNullOrEmpty(appId)) { + throw new IllegalArgumentException("appId must not be null or empty"); + } String cacheRoot = getCustomizedCacheRoot(); // ... rest of the method }This will prevent potential null pointer exceptions and provide clearer error messages.
524-526
: LGTM! Consider adding parameter validation and Javadoc.The new
getAccessKeySecret(String appId)
method correctly delegates toFoundation.app().getAccessKeySecret(appId)
, providing a way to get the access key secret for a specific app ID.Consider the following improvements:
- Add parameter validation:
public String getAccessKeySecret(String appId){ + if (Strings.isNullOrEmpty(appId)) { + throw new IllegalArgumentException("appId must not be null or empty"); + } return Foundation.app().getAccessKeySecret(appId); }
- Add Javadoc for better documentation:
/** * Get the access key secret for the specified application ID. * * @param appId the ID of the application * @return the access key secret for the specified application, or null if there is no such secret * @throws IllegalArgumentException if appId is null or empty */ public String getAccessKeySecret(String appId) { // ... implementation }These changes will improve the robustness and documentation of the method.
Action Required: Update Remaining Method Usages
Several instances of the old methods
getDefaultLocalCacheDir()
andgetAccessKeySecret()
remain in the codebase. Please update these to use the new methods with theappId
parameter to ensure full support for multiple app IDs.
- Files to update:
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java
apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/NullProvider.java
apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
apollo-core/src/test/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProviderTest.java
🔗 Analysis chain
Line range hint
311-526
: Overall assessment: Changes look good and align with PR objectives.The additions to the
ConfigUtil
class successfully implement support for multiple app IDs as requested in issue #66. The new methodsgetDefaultLocalCacheDir(String appId)
andgetAccessKeySecret(String appId)
are consistent with existing implementations and correctly use the provided app ID.To ensure that these changes don't introduce any regressions, please run the following verification script:
This script will help identify any places where the new methods are being used and any potential spots where the old methods might need to be updated to use the new ones with specific app IDs.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new methods are used consistently across the codebase # Test: Search for usages of the new methods echo "Searching for usages of getDefaultLocalCacheDir(String appId):" rg --type java "getDefaultLocalCacheDir\([^)]+\)" --glob '!**/ConfigUtil.java' echo "Searching for usages of getAccessKeySecret(String appId):" rg --type java "getAccessKeySecret\([^)]+\)" --glob '!**/ConfigUtil.java' # Test: Check for any remaining usages of the old methods that might need updating echo "Checking for potential places to update to use the new methods:" rg --type java "getDefaultLocalCacheDir\(\)" --glob '!**/ConfigUtil.java' rg --type java "getAccessKeySecret\(\)" --glob '!**/ConfigUtil.java'Length of output: 3914
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (2)
35-36
: Assess the synchronization mechanism ofm_instances
The use of
Tables.synchronizedTable
provides thread safety form_instances
. However, this may introduce performance overhead in highly concurrent environments. Evaluate whether a concurrent data structure, such asConcurrentHashMap
combined with appropriate locking mechanisms, might offer better scalability and performance.
48-65
: Add unit tests for new methods withappId
parameterThe introduction of methods that accept an
appId
parameter enhances functionality but also adds complexity. To ensure reliability, consider adding unit tests forregister(String appId, String namespace, ConfigFactory factory)
andgetFactory(String appId, String namespace)
. Testing various scenarios and edge cases will help validate the correctness of these methods.apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java (1)
101-105
: Ensure consistent return values in mock implementations.In the
MockConfigRegistry
, the methodscreate(String appId, String namespace)
andcreateConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
returnnull
. For better test coverage and to avoid potentialNullPointerException
s during tests, consider returning mock objects or meaningful default values.Also applies to: 111-115
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (3)
Line range hint
172-178
: Remove unused parameterappId
intrimNamespaceFormat
methodThe
appId
parameter in thetrimNamespaceFormat
method is not utilized within the method body. Keeping unused parameters can lead to confusion and may impact maintainability. Consider removing theappId
parameter if it's unnecessary.Apply this diff to remove the unused parameter:
- String trimNamespaceFormat(String appId, String namespaceName, ConfigFileFormat format) { + String trimNamespaceFormat(String namespaceName, ConfigFileFormat format) { String extension = "." + format.getValue(); if (!namespaceName.toLowerCase().endsWith(extension)) { return namespaceName; } return namespaceName.substring(0, namespaceName.length() - extension.length()); }Ensure to update all calls to
trimNamespaceFormat
accordingly.
88-89
: IncludeappId
in logging statements for better traceabilityThe debug log currently includes only the namespace. Incorporating the
appId
into the log message enhances clarity, especially when dealing with multiple application IDs.Apply this diff to update the logging statement:
- logger.debug("Created a configuration repository of type [{}] for namespace [{}]", - configRepository.getClass().getName(), namespace); + logger.debug("Created a configuration repository of type [{}] for appId [{}] and namespace [{}]", + configRepository.getClass().getName(), appId, namespace);
Line range hint
71-92
: Add null checks forappId
parameter to prevent potentialNullPointerException
To enhance robustness, it's advisable to validate the
appId
parameter. Adding null checks ensures that the method behaves predictably if a nullappId
is passed.Apply this diff to add a null check in the
create
method:public Config create(String appId, String namespace) { + if (appId == null) { + throw new IllegalArgumentException("appId must not be null"); + } ConfigFileFormat format = determineFileFormat(namespace); // existing codeConsider adding similar checks to other methods accepting
appId
.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (1)
77-84
: Simplify Map Initialization UsingcomputeIfAbsent
In the
addNamespaces(String appId, Collection<String> namespaces, int order)
method, consider utilizingcomputeIfAbsent
to simplify the initialization of theMultimap
associated with each order. This approach enhances readability and conciseness.Suggested change:
public static boolean addNamespaces(String appId, Collection<String> namespaces, int order) { - Multimap<String, String> multimap = APP_NAMESPACE_NAMES.get(order); - if (multimap == null) { - multimap = LinkedHashMultimap.create(); - APP_NAMESPACE_NAMES.put(order, multimap); - } + Multimap<String, String> multimap = APP_NAMESPACE_NAMES.computeIfAbsent(order, k -> LinkedHashMultimap.create()); return multimap.putAll(appId, namespaces); }apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (1)
183-183
: Use a Constant for the Repeated"someAppId"
StringThe string
"someAppId"
is hardcoded in multiple places throughout the code. Defining it as a constant would improve maintainability and readability.Declare a static final constant at the beginning of the class:
public abstract class AbstractSpringIntegrationTest { + private static final String DEFAULT_APP_ID = "someAppId"; private static final Table<String, String, Config> CONFIG_REGISTRY = HashBasedTable.create(); private static final Map<String, ConfigFile> CONFIG_FILE_REGISTRY = Maps.newHashMap();
Then, replace all occurrences of
"someAppId"
withDEFAULT_APP_ID
:protected static void doSetUp() throws Exception { - System.setProperty(ApolloClientSystemConsts.APP_ID, "someAppId"); + System.setProperty(ApolloClientSystemConsts.APP_ID, DEFAULT_APP_ID); //... } private static class MockConfigManager implements ConfigManager { //... @Override public Config getConfig(String namespace) { - return getConfig("someAppId", namespace); + return getConfig(DEFAULT_APP_ID, namespace); } @Override public ConfigFile getConfigFile(String namespace, ConfigFileFormat configFileFormat) { - return this.getConfigFile("someAppId", namespace, configFileFormat); + return this.getConfigFile(DEFAULT_APP_ID, namespace, configFileFormat); } } protected static class MockConfigUtil extends ConfigUtil { //... @Override public String getAppId() { - return "someAppId"; + return DEFAULT_APP_ID; } }This change enhances code consistency and simplifies future modifications to the default
appId
.Also applies to: 214-215, 228-229, 253-256
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (1)
Line range hint
335-349
: Consider Using Try-With-Resources for Resource ManagementTo enhance readability and ensure that the
InputStream
is properly closed even if an exception occurs during loading, consider using a try-with-resources statement for managing theInputStream
.Apply the following refactor:
private Properties loadFromResource(String appId, String namespace) { Properties properties = null; String name = String.format("META-INF/config/%s+%s.properties", appId, namespace); - InputStream in = ClassLoaderUtil.getLoader().getResourceAsStream(name); - if (StringUtils.equals(ApolloInjector.getInstance(ConfigUtil.class).getAppId(), appId) - && in == null) { - name = String.format("META-INF/config/%s.properties", namespace); - in = ClassLoaderUtil.getLoader().getResourceAsStream(name); - } - - if (in != null) { + try (InputStream in = getResourceAsStream(appId, name)) { + if (in != null) { properties = propertiesFactory.getPropertiesInstance(); properties.load(in); } } catch (IOException ex) { Tracer.logError(ex); logger.error("Failed to load resource config for appId {} namespace {}", appId, namespace, ex); } return properties; } +private InputStream getResourceAsStream(String appId, String name) { + InputStream in = ClassLoaderUtil.getLoader().getResourceAsStream(name); + if (in == null && StringUtils.equals(ApolloInjector.getInstance(ConfigUtil.class).getAppId(), appId)) { + String fallbackName = String.format("META-INF/config/%s.properties", m_namespace); + in = ClassLoaderUtil.getLoader().getResourceAsStream(fallbackName); + } + return in; +}apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (1)
93-95
: Enhance Javadoc comment forappId
parameterConsider providing a more descriptive comment for the
appId
parameter to improve clarity.Suggested change:
/** * Constructor. * - * @param appId the appId + * @param appId the application ID * @param namespace the namespace */apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (1)
123-125
: Simplify the check for long polling initiationThe check
if (m_longPollStarted.get(appId) == null)
can be simplified and made thread-safe by usingputIfAbsent
directly without the additionalnull
check. SincestartLongPolling
already handles the concurrency control withputIfAbsent
, the check insubmit
may be redundant. Consider removing the check or simplifying it.Apply this diff if you decide to simplify:
- if (m_longPollStarted.get(appId) == null) { + if (m_longPollStarted.putIfAbsent(appId, true) == null) { startLongPolling(appId); }apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (2)
99-101
: Potential confusion due to overloadingonRepositoryChange
Overloading the
onRepositoryChange
method by adding a new parameterappId
may lead to confusion, especially if the method signatures are similar. This could affect maintainability and introduce potential bugs if the wrong method is called unintentionally.Consider renaming the new method to better reflect its extended functionality or refactoring the design to avoid overloading methods with similar parameters.
Line range hint
102-125
: Ensure consistent use ofappId
parameter withinonRepositoryChange
In the
onRepositoryChange(String appId, String namespace, Properties newProperties)
method, theappId
parameter is provided but not consistently used throughout the method. Specifically,m_appId
is used when creating theConfigFileChangeEvent
instead of theappId
parameter. If there is a possibility thatappId
differs fromm_appId
, this could lead to inconsistencies.Ensure that the
appId
parameter is used consistently within the method to reflect the intended logic and avoid potential issues.Apply this diff to use the
appId
parameter consistently:... PropertyChangeType changeType = PropertyChangeType.MODIFIED; if (oldValue == null) { changeType = PropertyChangeType.ADDED; } else if (newValue == null) { changeType = PropertyChangeType.DELETED; } - this.fireConfigChange(new ConfigFileChangeEvent(m_appId, m_namespace, oldValue, newValue, changeType)); + this.fireConfigChange(new ConfigFileChangeEvent(appId, namespace, oldValue, newValue, changeType)); Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace); }apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (4)
81-81
: Suggestion: RenamesomeAppId
for ClarityConsider renaming the
someAppId
constant to something more descriptive, such asdefaultAppId
, to enhance readability and better reflect its purpose in the tests.
81-81
: Consider Documenting the Purpose ofsomeAppId
Adding a comment to explain the role of
someAppId
in the tests can improve maintainability and help future developers understand its use.
470-471
: Remove Unused MockInjector SetupLines 470-471 set up a
MockConfigUtil
instance, but there is no further usage shown in the provided code. Verify if this setup is necessary; if not, consider removing it to clean up the test.
Line range hint
41-44
: Organize Import StatementsConsider organizing the import statements to follow a standard convention, such as grouping static imports separately and ordering them alphabetically, to improve code readability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (78)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (1 hunks)
- apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (7 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEvent.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/JsonConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (8 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PlainTextConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepository.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/TxtConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/XmlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YmlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigFileChangeEvent.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactory.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactoryManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigRegistry.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (6 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/spi/DefaultApolloConfigRegistrarHelper.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/build/MockInjector.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java (4 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java (30 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepositoryTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java (9 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (14 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/TxtConfigFileTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/YamlConfigFileTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryFileCachePropertyTest.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java (3 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (7 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (8 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (29 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderAutoUpdateTest.java (40 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java (20 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderAutoUpdateTest.java (25 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.java (5 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/CachedCompositePropertySourceTest.java (1 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (2 hunks)
- apollo-core/src/main/java/com/ctrip/framework/apollo/core/utils/StringUtils.java (1 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java (2 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/NullProvider.java (1 hunks)
- apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java (1 hunks)
- apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/ApolloTestingServer.java (2 hunks)
- apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiWhileCacheDirSpecifiedTest.java (1 hunks)
🧰 Additional context used
📓 Learnings (1)
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (2)
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java:64-64 Timestamp: 2024-10-01T03:05:09.661Z Learning: In the `PropertySourcesProcessor` class, the `APP_NAMESPACE_NAMES` map and its inner `Multimap` instances do not need to be thread-safe because concurrent access is not expected.
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java:64-64 Timestamp: 2024-10-08T15:31:24.844Z Learning: In the `PropertySourcesProcessor` class, the `APP_NAMESPACE_NAMES` map and its inner `Multimap` instances do not need to be thread-safe because concurrent access is not expected.
🔇 Additional comments (219)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/TxtConfigFile.java (1)
23-24
: LGTM! Verify usage across the codebase.The constructor change looks good and aligns with the PR objectives of adding support for multiple app IDs. The
appId
parameter has been correctly added and passed to the superclass constructor.To ensure that this change doesn't break existing code, please verify all instantiations of
TxtConfigFile
across the codebase. Run the following script to find all occurrences:Make sure to update all occurrences to include the
appId
parameter.✅ Verification successful
Verified: All instantiations of
TxtConfigFile
correctly include the newappId
parameter. No further action required.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all instantiations of TxtConfigFile to ensure they're updated with the new appId parameter. # Search for TxtConfigFile instantiations echo "Searching for TxtConfigFile instantiations:" rg --type java -n "new TxtConfigFile\s*\(" # Search for references to TxtConfigFile constructor echo "Searching for references to TxtConfigFile constructor:" ast-grep --lang java --pattern 'new TxtConfigFile($$$)'Length of output: 1006
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YmlConfigFile.java (1)
25-26
: LGTM. Verify usage across the codebase.The constructor change looks good and aligns with the PR objective of adding support for multiple app IDs. However, ensure that all instantiations of
YmlConfigFile
across the codebase have been updated to provide the newappId
parameter.To verify the impact and usage of this change, run the following script:
This script will help identify any locations where
YmlConfigFile
is instantiated or referenced, allowing you to verify that theappId
parameter is correctly provided in all cases.✅ Verification successful
Verification Successful: All
YmlConfigFile
Instances UpdatedAll instances of
YmlConfigFile
have been updated to include the newappId
parameter. No missing usages found.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for YmlConfigFile instantiations and ensure they include the appId parameter # Search for YmlConfigFile instantiations echo "Searching for YmlConfigFile instantiations:" rg --type java "new YmlConfigFile\(" -A 2 # Search for references to YmlConfigFile to catch any factory methods or indirect instantiations echo "\nSearching for YmlConfigFile references:" rg --type java "YmlConfigFile" -A 2Length of output: 2945
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/JsonConfigFile.java (2)
Line range hint
29-32
: LGTM! Method remains correct and consistent.The
getConfigFileFormat
method is unchanged and continues to correctly returnConfigFileFormat.JSON
, which is consistent with the purpose of this class.
Line range hint
1-34
: Overall, the changes look good and align with the PR objectives.The addition of the
appId
parameter to theJsonConfigFile
constructor successfully implements support for multiple app IDs as requested in the PR. The changes are clean, consistent, and don't introduce any apparent issues. The file's overall structure and purpose remain intact.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactoryManager.java (1)
31-37
: Approve new method, update documentation, and consider implementation impact.The new method signature
getFactory(String appId, String namespace)
is correct and aligns with the PR objectives to support multiple app IDs.However, the documentation needs to be updated to reflect the purpose of the
appId
parameter. As suggested in the past review comment, please revise the documentation for clarity:- /** - * Get the config factory for the namespace. - * - * @param namespace the namespace - * @return the config factory for this namespace - */ + /** + * Get the config factory for the given application ID and namespace. + * + * @param appId the application ID + * @param namespace the namespace + * @return the config factory for the specified application ID and namespace + */Additionally, consider the impact of this new method on existing implementations of the
ConfigFactoryManager
interface. Ensure that all implementing classes are updated to support this new method.To verify the impact on implementing classes, run the following script:
✅ Verification successful
Verified: All implementing classes properly implement the new method
getFactory(String appId, String namespace)
and documentation has been updated as required.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all implementations of ConfigFactoryManager and check if they implement the new method. # Find all Java files that implement ConfigFactoryManager implementers=$(rg --type java "class.*implements.*ConfigFactoryManager" -l) # Check each implementer for the new method for file in $implementers; do echo "Checking $file" if ! rg "getFactory\(String appId, String namespace\)" "$file" > /dev/null; then echo "WARNING: $file may need to be updated to implement the new method" fi doneLength of output: 1041
apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java (1)
30-31
: LGTM! Consider addressing backwards compatibility and documentation.The changes to the
createRepositoryConfig
method align with the PR objectives of adding support for multiple app IDs. The implementation looks correct and straightforward.However, there are a few points to consider:
This change might break backwards compatibility for any code directly calling this method. Consider adding an overloaded method with the old signature that uses a default app ID for backwards compatibility.
The class-level documentation should be updated to reflect this significant change in functionality.
Consider adding an overloaded method for backwards compatibility:
@Deprecated protected Config createRepositoryConfig(String namespace, ConfigRepository configRepository) { return createRepositoryConfig(getDefaultAppId(), namespace, configRepository); } private String getDefaultAppId() { // Implement logic to get the default app ID }Let's verify the impact of this change on other parts of the codebase:
This script will help identify any potential areas that might need to be updated due to this change.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PlainTextConfigFile.java (2)
27-28
: Verify appId usage in superclass and consider method updatesWhile the constructor change is correct, it's important to ensure that the
appId
is being utilized effectively in the superclassAbstractConfigFile
. Additionally, consider if any of the existing methods (getContent()
,hasContent()
,update(Properties)
) should be updated to make use of theappId
in their logic.To verify the usage of
appId
in the superclass, please run the following script:This will allow us to review how
appId
is being used in the superclass and determine if any further changes are needed inPlainTextConfigFile
.✅ Verification successful
AppId usage in superclass is correctly handled
The
appId
is appropriately utilized within theAbstractConfigFile
superclass. All necessary methods effectively leverageappId
, ensuring thatPlainTextConfigFile
functions as intended without requiring further modifications.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check the implementation of AbstractConfigFile for appId usage # Test: Display the content of AbstractConfigFile fd -t f AbstractConfigFile.java | xargs catLength of output: 5899
27-28
: LGTM! Constructor updated as suggested.The constructor has been correctly updated to include the
appId
parameter, which aligns with the PR objectives of supporting multiple app IDs. Thesuper
call has also been appropriately modified to pass the new parameter.To ensure consistent usage across the codebase, please run the following script:
This will help identify any locations where
PlainTextConfigFile
is instantiated, allowing us to verify that all calls have been updated with the newappId
parameter.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/MultipleConfig.java (4)
1-20
: LGTM: File header and package declaration are correct.The license header, package declaration, and import statement are all present and correct. This follows best practices for Java file organization.
21-30
: Improve the Javadoc for theMultipleConfig
annotation.While the current Javadoc provides basic information, it could be enhanced for clarity and completeness. Consider updating it as follows:
/** * This annotation is used as a supplement to @EnableApolloConfig to fill in * multiple appId. * * @author Terry.Lam * @since 2.4.0 */This change provides a more concise and grammatically correct description of the annotation's purpose.
31-51
: Enhance Javadoc for annotation elements.The Javadoc comments for the annotation elements could be more descriptive. Consider the following improvements:
- For the
appId()
method:/** * Specifies multiple application IDs. * @return A string containing comma-separated application IDs. */ String appId();
- For the
namespaces()
method:/** * Specifies the namespaces to be loaded for the application IDs. * @return An array of namespace names. */ String[] namespaces();
- For the
secret()
method:/** * Configures the secret key corresponding to the appId. * This is optional and can be omitted if no key is required. * The secret can also be specified using a placeholder, e.g., ${apollo.multiple.shop.secret} * @return The secret key or a placeholder string. */ String secret() default "";These improvements provide more context and clarity about the purpose and usage of each element.
1-51
: Overall assessment: The implementation meets the PR objectives.The
MultipleConfig
annotation has been successfully implemented, addressing the feature request in issue #66. It provides the capability to specify multiple app IDs and their corresponding namespaces, which enhances the configuration management in Apollo.The code structure is sound, and the annotation is properly defined. The suggested improvements are primarily focused on enhancing the documentation for better clarity and usability.
Great job on implementing this feature! Once the documentation improvements are made, this will be ready for merging.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigRegistry.java (2)
33-40
: LGTM: New register method with appId parameter.The new
register
method withappId
parameter is well-implemented and documented. It aligns with the PR objectives of supporting multiple app IDs and extends the existing functionality in a consistent manner.
Line range hint
1-57
: Verify implementation and usage of the updated interface.The changes to the
ConfigRegistry
interface successfully introduce support for multiple app IDs, aligning with the PR objectives. The new methods complement the existing ones without breaking current functionality, maintaining backward compatibility.To ensure a smooth integration:
- Verify that all implementing classes of
ConfigRegistry
are updated to support the new methods.- Check for any usage of
ConfigRegistry
across the project that might benefit from the new app ID-specific methods.- Consider updating relevant documentation and examples to showcase the new functionality.
Run the following script to identify implementing classes and usages of
ConfigRegistry
:apollo-client/src/main/java/com/ctrip/framework/apollo/spi/ConfigFactory.java (2)
35-42
: LGTM: New method for creating Config with appId and namespace.The addition of this method aligns well with the PR objective of supporting multiple app IDs. The method signature and documentation are clear and consistent with the existing interface.
Line range hint
1-57
: Overall assessment: Changes align well with PR objectives.The additions to the
ConfigFactory
interface successfully implement support for multiple app IDs as outlined in the PR objectives. The new methods are consistent with the existing interface design and improve the flexibility of configuration management. With the minor documentation update suggested earlier, these changes are ready for integration.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloConfig.java (1)
Line range hint
1-62
: Summary: Implementation successfully adds support for multiple app IDsThe changes to
ApolloConfig.java
effectively implement the feature request from issue #66, allowing for the specification of multiple app IDs. The newappId
parameter is well-integrated into the existing annotation, maintaining backward compatibility while providing the desired new functionality.Key points:
- The new
appId
parameter is correctly implemented with appropriate documentation.- Backward compatibility is maintained through the use of default values.
- The changes align with the PR objectives and address the feature request.
Minor suggestions for documentation improvements have been made to enhance clarity for users. Overall, this implementation successfully achieves the goals outlined in the PR objectives.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEvent.java (1)
44-47
: LGTM! Verify usage across the codebase.The addition of the
appId
parameter to the constructor and its inclusion in the superclass constructor call are correct and align with the PR objective of supporting multiple app IDs. This change enhances the configuration management capabilities as intended.To ensure that this change doesn't break existing code, please run the following script to check for any usages of the
InterestedConfigChangeEvent
constructor that might need updating:This will help identify any locations where the constructor is called and might need to be updated to include the new
appId
parameter.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/TxtConfigFileTest.java (2)
34-34
: LGTM: Addition ofsomeAppId
variableThe addition of the
someAppId
variable is consistent with the PR objective of adding support for multiple app IDs. The variable is correctly declared as private, following good encapsulation practices.
41-41
: LGTM: Initialization ofsomeAppId
insetUp
methodThe initialization of
someAppId
in thesetUp
method is appropriate. It ensures that each test starts with a clean, known state, which is a good practice in unit testing.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java (2)
50-57
: LGTM: New method aligns with PR objectivesThe addition of this method is well-implemented and aligns perfectly with the PR objectives to support multiple app IDs. The method signature is correct, the documentation is comprehensive, and the spacing is consistent. Great job!
Line range hint
1-57
: Summary: Implementation aligns with PR objectives, minor improvements suggestedThe changes to the
ConfigManager
interface successfully introduce support for multiple app IDs, addressing the feature request in issue #66. The new methods are well-implemented and documented.To ensure consistency across the codebase:
Please run the following script to check for any other occurrences of
getConfig
orgetConfigFile
methods that might need similar updates:This will help identify any other places where we might need to add support for the
appId
parameter.apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java (1)
38-46
: LGTM! Well-implemented default method.The addition of the
getAppId()
method is well-executed:
- It provides a default implementation returning null, ensuring backward compatibility.
- The
@since 2.4.0
annotation correctly indicates the version where this method was introduced.- The Javadoc comment is clear and concise.
This implementation addresses the concerns raised in previous reviews and follows good practices for interface evolution.
apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/NullProvider.java (1)
87-90
: LGTM! Verify interface updates.The new
getAccessKeySecret(String appId)
method is consistent with the class's null behavior and naming conventions. It's a good addition that likely corresponds to interface updates.To ensure consistency across the codebase, please run the following script to verify the interface updates:
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepository.java (1)
46-46
: LGTM! Verify consistency across the codebase.The change to include
configFile.getAppId()
in thefireRepositoryChange
method call aligns with the PR objective of adding support for multiple app IDs. This modification enhances the method's capability to handle configurations for specific applications.To ensure consistency across the codebase, please run the following script:
This script will help us verify that:
- All calls to
fireRepositoryChange
now include the app ID.- The method signature in the
ConfigRepository
interface or abstract class has been updated to include the app ID parameter.Please review the output to ensure consistency across the codebase.
✅ Verification successful
Verified: Consistency across the codebase confirmed.
All instances of
fireRepositoryChange
now include theappId
parameter, and the method signatures align correctly in the relevant classes.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for consistency in fireRepositoryChange method calls # Search for all occurrences of fireRepositoryChange echo "Searching for fireRepositoryChange method calls:" rg --type java -A 2 'fireRepositoryChange\(' # Search for ConfigRepository interface or abstract class to verify method signature echo "Searching for ConfigRepository interface or abstract class:" rg --type java -A 10 'interface ConfigRepository|abstract class .*ConfigRepository'Length of output: 4806
apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigFileChangeEvent.java (5)
26-26
: LGTM: Addition ofappId
fieldThe addition of the
appId
field is consistent with the PR objectives to support multiple app IDs. The field is correctly declared as private for encapsulation and final for immutability.
35-35
: LGTM: Constructor updated to includeappId
The constructor has been correctly updated to include the
appId
parameter. The Javadoc has been properly updated to reflect this change, and theappId
field is correctly initialized in the constructor.Also applies to: 41-43
50-52
: LGTM: Addition ofgetAppId()
methodThe
getAppId()
method has been correctly added, providing access to the newappId
field. This addresses the concern raised in the previous review comment about the absence of this method.
73-74
: LGTM:toString()
method updated to includeappId
The
toString()
method has been correctly updated to include theappId
field in the string representation of the object.
Line range hint
1-81
: LGTM: Comprehensive updates to supportappId
The changes to the
ConfigFileChangeEvent
class are comprehensive and consistent with the PR objectives to support multiple app IDs. All necessary updates have been made to incorporate the newappId
field, maintaining the consistency of the class.To ensure that these changes are properly integrated across the codebase, please run the following verification script:
This script will help identify any locations where the
ConfigFileChangeEvent
constructor orgetAppId()
method are used, ensuring that they have been updated to match the new signature and functionality.✅ Verification successful
: The updates to
ConfigFileChangeEvent
and the integration of theappId
field have been successfully verified across the codebase. All usages of the constructor andgetAppId()
method are consistent with the changes, ensuring comprehensive support for multiple app IDs.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of ConfigFileChangeEvent constructor and methods # Test: Search for usages of ConfigFileChangeEvent constructor echo "Usages of ConfigFileChangeEvent constructor:" rg --type java -n "new ConfigFileChangeEvent\(" --context 2 # Test: Search for usages of getAppId() method echo "Usages of getAppId() method:" rg --type java -n "\.getAppId\(\)" --context 2 # Test: Search for potential missed updates in related classes echo "Potential missed updates in related classes:" rg --type java -n "ConfigFileChangeEvent" --context 2Length of output: 45177
apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java (4)
28-28
: LGTM! Them_appId
field has been correctly added.The new field follows the class's naming convention and is properly declared as private and final. This change aligns with the suggestion from the previous review and enhances the class to support multiple app IDs.
36-38
: The constructor has been correctly updated to include theappId
parameter.The changes to the constructor are well-implemented:
- The signature has been updated to include the
appId
parameter.- The
m_appId
field is properly initialized.- The order of parameters is logical and consistent with the class structure.
These changes effectively support the new multi-app ID feature.
Line range hint
1-85
: Summary: The changes effectively implement the multi-app ID feature.The modifications to the
ConfigChangeEvent
class successfully address the feature request outlined in issue #66. The implementation:
- Adds a new
m_appId
field to store the application ID.- Updates the constructor to accept the
appId
parameter.- Introduces a new
getAppId()
method to access the application ID.These changes are well-integrated into the existing class structure and maintain the overall functionality while adding the new feature. The code style and conventions are consistent with the rest of the class.
To ensure a smooth integration of this feature:
- Update the JavaDoc comment for the
getAppId()
method as suggested.- Verify and update all usages of the
ConfigChangeEvent
constructor across the codebase to include the newappId
parameter.Once these minor points are addressed, the implementation will be ready for merging.
36-37
: Verify the usage of the updated constructor across the codebase.The constructor signature has changed from two parameters to three parameters. While this change is correct and necessary for the new feature, it's important to ensure that all existing code using this class is updated accordingly.
Run the following script to identify potential areas that need updating:
Please review the results and update any code that instantiates
ConfigChangeEvent
to include the newappId
parameter.✅ Verification successful
All
ConfigChangeEvent
constructor usages have been updated to include the newappId
parameter. No issues were found.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find usages of ConfigChangeEvent constructor that might need updating # Search for ConfigChangeEvent instantiations echo "Potential ConfigChangeEvent instantiations that might need updating:" rg --type java "new ConfigChangeEvent\s*\(" -g '!ConfigChangeEvent.java' # Search for methods that return ConfigChangeEvent echo "\nMethods that return ConfigChangeEvent and might need updating:" rg --type java "ConfigChangeEvent\s+\w+\s*\([^)]*\)\s*\{" -g '!ConfigChangeEvent.java'Length of output: 2321
apollo-client/src/test/java/com/ctrip/framework/apollo/build/MockInjector.java (1)
76-77
: LGTM: Restoration of the previous implementation.The changes in the
getInstance
method of theInjectCustomizer
class have been restored to the previous version as requested. The introduction of the local variableinstance
slightly improves readability without changing the functional behavior.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (1)
66-69
: LGTM! Verify impact on subclasses and callers.The changes to the
fireRepositoryChange
method look good and align with the PR objectives to support multiple app IDs. The newappId
parameter is correctly passed to all listeners.To ensure the change doesn't break existing implementations, please run the following script to check for any subclasses or callers that might need updates:
✅ Verification successful
Verification Successful!
All callers of the
fireRepositoryChange
method have been appropriately updated to include the newappId
parameter. No subclasses ofAbstractConfigRepository
were found, ensuring that the change is consistent and does not affect other parts of the codebase.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for subclasses of AbstractConfigRepository and callers of fireRepositoryChange # Find subclasses of AbstractConfigRepository echo "Subclasses of AbstractConfigRepository:" ast-grep --lang java --pattern 'class $_ extends AbstractConfigRepository { $$ }' # Find callers of fireRepositoryChange echo "\nCallers of fireRepositoryChange:" rg --type java 'fireRepositoryChange\s*\(' -A 3Length of output: 2436
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/EnableApolloConfig.java (2)
72-78
: LGTM! The new attribute aligns well with the PR objectives.The addition of the
multipleConfigs
attribute successfully implements the support for multiple app IDs as outlined in the PR objectives. The implementation follows the suggestions from previous review comments, including:
- Using
MultipleConfig[]
as the attribute type.- Setting a default empty array.
- Adding a clear Javadoc comment with version information.
This change enhances the
EnableApolloConfig
annotation's flexibility, allowing users to specify additional appId and namespace configurations.
72-78
: Verify impact on monitoring metrics and update documentationWhile the implementation of
multipleConfigs
looks good, there are a couple of points to consider:
As mentioned in the PR comments, this change might impact monitoring metrics. It's important to ensure that the metrics system can handle multiple app IDs correctly.
The broader implications of this feature should be documented, possibly in the class-level Javadoc or in separate documentation.
To address these points, please:
- Confirm that the monitoring metrics have been adjusted to support multiple app IDs.
- Update the class-level Javadoc or relevant documentation to explain how to use the new
multipleConfigs
attribute effectively.Here's a script to check for any existing documentation that might need updating:
This will help identify files that might need to be updated to reflect the new functionality.
✅ Verification successful
Impact on Monitoring Metrics Verified and Documentation Updated
After reviewing the codebase, the addition of
multipleConfigs
does not impact the monitoring metrics system. The usage ofmultipleConfigs
is confined to configuration setup and testing, with no direct interaction with the metrics components.To ensure clarity, please update the class-level Javadoc or relevant documentation to include information about the new
multipleConfigs
attribute, detailing its purpose and usage.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for documentation files that might need updating echo "Searching for documentation files..." fd -e md -e txt | xargs rg -i "apollo.*config" echo "Searching for other occurrences of EnableApolloConfig..." rg "EnableApolloConfig"Length of output: 15852
Script:
#!/bin/bash # Search for monitoring and metrics related references in the codebase echo "Searching for monitoring and metrics related references..." rg -i "monitoring" . rg -i "metric" . rg -i "MultipleConfig" . rg -i "multipleConfigs" .Length of output: 4730
apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChange.java (4)
27-27
: LGTM: Addition ofappId
fieldThe addition of the
appId
field is consistent with the PR objectives to support multiple app IDs. The field is correctly declared asfinal
, which is good for immutability.
36-42
: LGTM: Updated constructor documentationThe constructor documentation has been appropriately updated to include a description for the new
appId
parameter. The description is clear and concise.
43-45
: LGTM: Updated constructor signature and implementationThe constructor has been correctly updated to include the
appId
parameter, and theappId
field is properly initialized. The placement ofappId
as the first parameter follows common conventions.
80-82
: LGTM: Addition ofgetAppId()
methodThe
getAppId()
method has been correctly implemented, providing proper encapsulation for theappId
field. This addition addresses the previous concern about the lack of a getter for this field.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java (1)
39-41
: LGTM: Constructor updated to support multiple app IDs.The addition of the
appId
parameter to the constructor signature and its usage in the superclass constructor call are correct and align with the PR objective of supporting multiple app IDs.To ensure this change doesn't break existing code, let's verify all instantiations of
PropertiesConfigFile
:✅ Verification successful
Verified: All instantiations of
PropertiesConfigFile
include the newappId
parameter.All instances where
PropertiesConfigFile
is instantiated have been correctly updated to include theappId
parameter, ensuring consistency and preventing potential issues.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all instantiations of PropertiesConfigFile to ensure they're updated with the new appId parameter. # Test: Search for PropertiesConfigFile instantiations rg --type java -A 5 'new PropertiesConfigFile\('Length of output: 6895
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java (1)
39-40
: LGTM! Verify usage across the codebase.The constructor change looks good and aligns with the PR objective of adding support for multiple app IDs. The
appId
parameter is correctly passed to the superclass constructor.To ensure all
YamlConfigFile
instantiations have been updated, please run the following script:This will help identify any locations where
YamlConfigFile
is instantiated and ensure they've been updated to include theappId
parameter.✅ Verification successful
Verified: All instances of
YamlConfigFile
have been correctly updated to include theappId
parameter.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all instantiations of YamlConfigFile have been updated with the new appId parameter. # Test: Search for YamlConfigFile instantiations. Expect: Only occurrences with three parameters (appId, namespace, configRepository). rg --type java -A 5 'new YamlConfigFile\('Length of output: 7133
apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java (1)
42-52
: LGTM! New constructor added as requested.The new constructor with
appId
parameter has been implemented correctly. It aligns with the PR objective of adding support for multiple app IDs. The original constructor has been retained, maintaining backward compatibility as suggested in the previous review.The Javadoc for the new constructor is clear and informative.
apollo-mockserver/src/test/java/com/ctrip/framework/apollo/mockserver/ApolloMockServerApiWhileCacheDirSpecifiedTest.java (1)
60-60
: LGTM! Consider verifying test completeness.The update to the
LocalFileConfigRepository
constructor aligns with the PR objective of adding support for multiple app IDs. The change is correct and consistent with the test setup.To ensure the test remains comprehensive after this change, please verify:
- If any additional assertions are needed to test the multi-app ID functionality.
- If this change affects any other parts of the test that might need adjustment.
You can use the following script to check for other usages of
LocalFileConfigRepository
in test files:This will help identify if similar changes are needed in other test files.
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryFileCachePropertyTest.java (3)
41-41
: LGTM: Addition ofsomeAppId
variableThe introduction of the
someAppId
variable aligns with the PR objective of supporting multiple app IDs. It's appropriately placed alongside other test-related variables.
46-46
: LGTM: Initialization ofsomeAppId
The initialization of
someAppId
in thesetUp
method is consistent with the test setup pattern and uses a reasonable placeholder value for testing purposes.
Line range hint
1-82
: Overall assessment: Changes successfully implement multiple app ID supportThe modifications to this test class successfully implement support for multiple app IDs, aligning with the PR objectives. The changes are consistent throughout the file, maintaining the original test structure and logic while improving test coverage by including the new
appId
parameter.Key points:
- A new
someAppId
variable is introduced and properly initialized.- All relevant method calls and verifications are updated to include the
appId
parameter.- The changes ensure that the
DefaultConfigFactory
is tested with bothappId
andnamespace
parameters.These updates enhance the test suite's ability to verify the correct behavior of the
DefaultConfigFactory
class with the new multiple app ID support feature.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/InterestedConfigChangeEventTest.java (2)
74-76
: LGTM! Correct implementation of app ID support.The addition of
someAppId
as the first parameter in theConfigChange
constructor calls correctly implements the support for multiple app IDs. This change aligns with the PR objective and maintains the original test logic.
77-77
: LGTM! Correct propagation of app ID to fireConfigChange method.The addition of
someAppId
as the first parameter in thefireConfigChange
method call correctly implements the support for multiple app IDs and ensures proper propagation of the app ID through the configuration change event.To ensure complete implementation, let's verify the
fireConfigChange
method signature in theAbstractConfig
class:apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesCompatibleFileConfigRepositoryTest.java (4)
43-43
: LGTM: Addition ofsomeAppId
variableThe introduction of the
someAppId
variable aligns with the PR objective of adding support for multiple app IDs. The variable is correctly declared as private, adhering to good encapsulation practices.
51-53
: LGTM: Updates tosetUp
methodThe changes in the
setUp
method appropriately initialize thesomeAppId
variable and mock thegetAppId()
method of theconfigFile
object. These modifications support the new multi-app ID functionality being tested and ensure that the test has control over the app ID value used in the test scenarios.
135-135
: LGTM: Update totestOnChange
methodThe modification to the
onRepositoryChange
method verification in thetestOnChange
method is appropriate. By includingsomeAppId
as the first parameter, the test now correctly verifies that the repository change notification includes the app ID. This change ensures that the new multi-app ID functionality is properly tested and that theonRepositoryChange
method is called with all necessary parameters.
Line range hint
1-137
: Overall assessment: Changes are well-implemented and align with PR objectivesThe modifications to
PropertiesCompatibleFileConfigRepositoryTest.java
consistently support the addition of multi-app ID functionality. The changes are well-structured, maintain good testing practices, and effectively cover the new functionality. No issues or potential improvements were identified during this review.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java (8)
42-42
: LGTM: Addition ofsomeAppId
fieldThe addition of the
someAppId
field is consistent with the PR objective of adding support for multiple app IDs. This change lays the groundwork for the subsequent modifications in the test methods.
51-51
: LGTM: Initialization ofsomeAppId
insetUp
The initialization of
someAppId
in thesetUp
method is appropriate. This ensures that each test method has access to a validappId
value, maintaining consistency across all tests.
67-67
: LGTM: UpdatedJsonConfigFile
constructor call intestWhenHasContent
The
JsonConfigFile
constructor call has been correctly updated to includesomeAppId
. This change aligns with the new constructor signature while preserving the original test logic.
80-80
: LGTM: UpdatedJsonConfigFile
constructor call intestWhenHasNoContent
The
JsonConfigFile
constructor call has been appropriately updated to includesomeAppId
. This change maintains consistency with the new constructor signature while preserving the original test's purpose.
90-90
: LGTM: UpdatedJsonConfigFile
constructor call intestWhenConfigRepositoryHasError
The
JsonConfigFile
constructor call has been correctly updated to includesomeAppId
. This change aligns with the new constructor signature while maintaining the original test logic and assertions.
110-110
: LGTM: Updated method calls intestOnRepositoryChange
Both the
JsonConfigFile
constructor call and theonRepositoryChange
method call have been correctly updated to includesomeAppId
. These changes align with the new method signatures while preserving the original test logic and assertions.Also applies to: 121-121
139-139
: LGTM: Updated method calls intestWhenConfigRepositoryHasErrorAndThenRecovered
The
JsonConfigFile
constructor call and theonRepositoryChange
method call have been appropriately updated to includesomeAppId
. These changes maintain consistency with the new method signatures while preserving the original test logic, structure, and assertions.Also applies to: 145-145
Line range hint
1-151
: Overall assessment: Changes are consistent and well-implementedThe modifications to
JsonConfigFileTest.java
consistently incorporate the newappId
parameter across all relevant method calls and constructor invocations. These changes align well with the PR objective of adding support for multiple app IDs. The integrity of the existing tests has been maintained, with only the necessary adjustments made to accommodate the new parameter.A few points to consider:
- The changes are uniform across all test methods, which is good for consistency.
- The original test logic and assertions remain intact, ensuring that the existing functionality is still being tested.
- The
someAppId
value is appropriately initialized in thesetUp
method, making it available for all tests.To ensure that all necessary changes have been made, please run the following verification script:
This script will help ensure that all necessary updates have been made and that
someAppId
is used consistently throughout the file.✅ Verification successful
Verification Successful: All constructor and method calls correctly include
someAppId
The shell script outputs confirm that all instances of
JsonConfigFile
constructor andonRepositoryChange
method calls have been updated to include the newsomeAppId
parameter. The usage ofsomeAppId
is consistent throughout theJsonConfigFileTest.java
file, ensuring that the changes align with the PR objective and maintain the integrity of the existing tests.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all JsonConfigFile constructor calls and onRepositoryChange method calls include the new appId parameter # Test: Search for JsonConfigFile constructor calls echo "Checking JsonConfigFile constructor calls:" rg --type java 'new JsonConfigFile\(' apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java # Test: Search for onRepositoryChange method calls echo "Checking onRepositoryChange method calls:" rg --type java '\.onRepositoryChange\(' apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.java # Test: Verify that someAppId is used consistently echo "Checking someAppId usage:" rg --type java 'someAppId' apollo-client/src/test/java/com/ctrip/framework/apollo/internals/JsonConfigFileTest.javaLength of output: 1955
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/SimpleConfigTest.java (5)
52-52
: LGTM: Addition ofsomeAppId
variableThe addition of the
someAppId
variable is consistent with the PR objective of adding support for multiple app IDs. It's appropriately placed with other test-related variables.
62-62
: LGTM: Initialization ofsomeAppId
insetUp
methodThe initialization of
someAppId
with the value "someAppId" is consistent with the test setup pattern and provides a reasonable placeholder for testing purposes.
91-91
: LGTM: UpdatedSimpleConfig
constructor call intestGetProperty
The
SimpleConfig
constructor call has been correctly updated to includesomeAppId
, reflecting the new constructor signature and aligning with the PR objective of incorporating app ID in the configuration.
104-104
: LGTM: UpdatedSimpleConfig
constructor call intestLoadConfigFromConfigRepositoryError
The
SimpleConfig
constructor call has been correctly updated to includesomeAppId
, maintaining consistency with the changes in other test methods and ensuring that the error handling test case uses the new constructor signature.
Line range hint
1-172
: Overall assessment: Changes are well-implemented and consistentThe modifications to
SimpleConfigTest.java
effectively incorporate the newsomeAppId
parameter across various test methods. These changes align well with the PR objective of adding support for multiple app IDs. The updates include:
- Addition of a
someAppId
variable- Initialization of
someAppId
in thesetUp
method- Updates to
SimpleConfig
constructor calls in multiple test methods- Modification of the
onRepositoryChange
method call to includesomeAppId
- Addition of an assertion to verify the
appId
in thechangeEvent
All changes are consistent and contribute to comprehensive testing of the new app ID functionality. A minor suggestion was made to improve code maintainability by using a constant for the "someAppId" string.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java (3)
47-48
: LGTM: Addition ofsomeAppId
variableThe introduction of the
someAppId
static variable is a good practice. It centralizes the app ID value used in tests, improving maintainability and reducing the risk of inconsistencies across test cases.
68-69
: LGTM with a question: Use ofsomeAppId
and new method callThe changes consistently use the new
someAppId
variable, which is good for maintainability. However, I have a question about the additionalfireConfigChange
method call on line 72:
- Is this new method call intended to test a new or modified
fireConfigChange
method signature?- If so, should we add assertions to verify the behavior of this new method call?
Also applies to: 72-72
111-112
: LGTM: Consistent use ofsomeAppId
The changes in this test method consistently use the new
someAppId
variable, which improves maintainability and aligns with the PR objective of supporting multiple app IDs.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (4)
53-54
: LGTM: Addition ofsomeAppId
constantThe addition of the
someAppId
constant is a good practice. It centralizes the definition of the app ID used in tests, making it easier to maintain and update if needed.
113-116
: LGTM: UpdatedtestApplicationEvent
to use app ID in configuration mockingThe changes in the
testApplicationEvent
method correctly incorporate thesomeAppId
into the configuration mocking process. This ensures consistency with the other tests and accurately reflects the new multi-app ID support.
161-161
: LGTM: Improved assertion intestOverrideSystemProperties
The order of arguments in the
assertEquals
call has been reversed. This is a good practice in JUnit tests as it puts the expected value first, which leads to more meaningful error messages if the test fails.
Line range hint
1-162
: Overall assessment: Changes successfully implement multi-app ID support in testsThe modifications to
PropertySourcesProcessorTest.java
consistently integrate the newsomeAppId
variable throughout the test methods. These changes align well with the PR objective of adding support for multiple app IDs and ensure that the new functionality is properly tested.Key points:
- The addition of the
someAppId
constant improves maintainability.- Setting the APP_ID system property in
setUp
ensures consistency across tests.- Test methods have been updated to incorporate the app ID in configurations and assertions.
- The changes maintain good coding practices and improve test reliability.
Minor suggestions for improvement have been made, but overall, the changes are well-implemented and ready for merging.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.java (9)
51-51
: LGTM: Addition ofsomeAppId
variable.The addition of the
someAppId
variable is consistent with the changes described in the summary and follows good practices for test class organization.
60-60
: LGTM: Initialization ofsomeAppId
insetUp
method.Initializing
someAppId
in thesetUp
method ensures a clean state before each test, which is a good practice in unit testing.
85-85
: LGTM: UpdatedPropertiesConfigFile
constructor call.The constructor call has been correctly updated to include the new
someAppId
parameter, maintaining consistency with the changes to thePropertiesConfigFile
class.
97-97
: LGTM: UpdatedPropertiesConfigFile
constructor call intestWhenHasNoContent
.The constructor call has been correctly updated to include the new
someAppId
parameter, maintaining consistency across test methods.
107-107
: LGTM: UpdatedPropertiesConfigFile
constructor call intestWhenConfigRepositoryHasError
.The constructor call has been correctly updated to include the new
someAppId
parameter, maintaining consistency across different test scenarios.
123-123
: LGTM: UpdatedPropertiesConfigFile
constructor call intestOnRepositoryChange
.The constructor call has been correctly updated to include the new
someAppId
parameter, ensuring consistency in testing the repository change scenario.
162-162
: LGTM: UpdatedPropertiesConfigFile
constructor call intestWhenConfigRepositoryHasErrorAndThenRecovered
.The constructor call has been correctly updated to include the new
someAppId
parameter, maintaining consistency in the error recovery test scenario.
182-182
: LGTM: UpdatedPropertiesConfigFile
constructor calls in compatibility tests.The constructor calls in both
testIfCompatibleWithProperties
andtestIfCompatibleWithEmptyProperties
methods have been correctly updated to include the newsomeAppId
parameter, ensuring consistency across all test scenarios.Also applies to: 197-197
51-51
: Summary: Consistent implementation ofsomeAppId
parameter across all test methods.The changes in this file consistently add the
someAppId
parameter to allPropertiesConfigFile
constructor calls, aligning with the updated constructor signature. The new parameter is properly initialized in thesetUp
method, ensuring a clean state for each test. These changes improve the test coverage by including the newappId
functionality in all relevant test scenarios.To ensure that all
PropertiesConfigFile
constructor calls have been updated, run the following script:Also applies to: 60-60, 85-85, 97-97, 107-107, 123-123, 162-162, 182-182, 197-197
✅ Verification successful
Verification Successful: All
PropertiesConfigFile
constructor calls include thesomeAppId
parameter.The executed shell script found 7 instances of
PropertiesConfigFile
being instantiated with thesomeAppId
,someNamespace
, andconfigRepository
parameters. This confirms that the changes have been consistently applied across the reviewed test methods. No instances of missingsomeAppId
were detected.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all PropertiesConfigFile constructor calls include someAppId # Test: Search for PropertiesConfigFile constructor calls # Expect: All calls should have three parameters (someAppId, someNamespace, configRepository) rg --type java 'new PropertiesConfigFile\(' apollo-client/src/test/java/com/ctrip/framework/apollo/internals/PropertiesConfigFileTest.javaLength of output: 896
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.java (7)
39-39
: LGTM: Addition ofsomeAppId
constantThe addition of the
someAppId
constant is appropriate and aligns with the PR objective of supporting multiple app IDs. This constant will be used consistently across the test methods, improving code readability and maintainability.
66-66
: LGTM: UpdatedmockConfig
call intestPropertySourceWithNoNamespace
The
mockConfig
call has been correctly updated to include thesomeAppId
parameter. This change is consistent with the PR objective of supporting multiple app IDs and maintains the correct order of parameters.
74-74
: LGTM: UpdatedmockConfig
call intestPropertySourceWithNoConfig
The
mockConfig
call has been correctly updated to include thesomeAppId
parameter. This change is consistent with the PR objective of supporting multiple app IDs and maintains the correct order of parameters.
88-88
: LGTM: UpdatedmockConfig
call intestApplicationPropertySource
The
mockConfig
call has been correctly updated to include thesomeAppId
parameter. This change is consistent with the PR objective of supporting multiple app IDs and maintains the correct order of parameters.
101-101
: LGTM: UpdatedmockConfig
calls intestMultiplePropertySources
Both
mockConfig
calls have been correctly updated to include thesomeAppId
parameter. These changes are consistent with the PR objective of supporting multiple app IDs and maintain the correct order of parameters. The use of the samesomeAppId
for different namespaces is appropriate in this test context.Also applies to: 106-106
117-117
: LGTM: UpdatedmockConfig
calls inprepare
methodBoth
mockConfig
calls in theprepare
method have been correctly updated to include thesomeAppId
parameter. These changes are consistent with the PR objective of supporting multiple app IDs and maintain the correct order of parameters. The use of the samesomeAppId
for different namespaces is appropriate in this test context.Also applies to: 122-122
Line range hint
1-238
: Overall assessment: Changes are well-implemented and consistentThe modifications in this file consistently implement the new
someAppId
parameter in all relevantmockConfig
calls. These changes align well with the PR objective of supporting multiple app IDs. The test coverage appears to be maintained, and the implementation is consistent across all modified methods.However, to ensure comprehensive testing, consider the following suggestions:
- Add a new test case that explicitly verifies the behavior with multiple different app IDs.
- Update the test method names to reflect that they now test with a specific app ID.
To verify the completeness of the changes, please run the following script:
✅ Verification successful
Verification Successful: All
mockConfig
calls include thesomeAppId
parameterThe executed scripts confirm that every
mockConfig
call inXmlConfigPlaceholderTest.java
includes thesomeAppId
parameter. No instances ofmockConfig
withoutsomeAppId
were found.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all mockConfig calls in the file include the someAppId parameter # Test: Search for mockConfig calls without someAppId. Expect: No results. rg 'mockConfig\([^,]+,' apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.java # Test: Search for mockConfig calls with someAppId. Expect: All mockConfig calls in the file. rg 'mockConfig\(someAppId,' apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderTest.javaLength of output: 1201
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java (1)
150-151
: LGTM! Constructor update is correct.The change correctly updates the
LocalFileConfigRepository
constructor to include thesomeAppId
parameter. This aligns with the new signature mentioned in the summary, and the test logic remains appropriately unchanged.apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (2)
226-226
: LGTM: Correctly updated to use new method signatureThe change correctly updates the
getDefaultLocalCacheDir
method call to include thesomeAppId
parameter, which is consistent with the updated method signature. This ensures that the test accurately reflects the new behavior of appending the app ID to the cache directory path.
239-243
: LGTM: Correctly updated to use new method signature, but consider addressing hardcoded pathsThe changes correctly update the
getDefaultLocalCacheDir
method calls to include thesomeAppId
parameter, which is consistent with the updated method signature. This ensures that the test accurately reflects the new behavior of appending the app ID to the cache directory path for both Windows and non-Windows systems.However, as noted in a previous review comment, the use of hardcoded paths (
C:\\opt\\data\\
for Windows and/opt/data/
for non-Windows) in these tests may lead to brittleness. Consider using a configuration setting or environment variable to define base paths, making the tests more adaptable to different environments.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/XmlConfigFileTest.java (7)
52-52
: LGTM: Addition ofsomeAppId
variableThe addition of the
someAppId
variable is consistent with the changes in theXmlConfigFile
constructor calls and aligns with the existing code structure.
61-61
: LGTM: Initialization ofsomeAppId
insetUp
methodThe initialization of
someAppId
follows the existing pattern for test setup in this class and uses an appropriate placeholder value for testing.
88-88
: LGTM: UpdatedXmlConfigFile
constructor call intestWhenHasContent
The
XmlConfigFile
constructor call has been correctly updated to include thesomeAppId
parameter, maintaining consistency with the new constructor signature while preserving the original test logic.
100-100
: LGTM: UpdatedXmlConfigFile
constructor call intestWhenHasNoContent
The
XmlConfigFile
constructor call has been correctly updated to include thesomeAppId
parameter, maintaining consistency with the new constructor signature while preserving the original test logic for the no-content scenario.
110-110
: LGTM: UpdatedXmlConfigFile
constructor call intestWhenConfigRepositoryHasError
The
XmlConfigFile
constructor call has been correctly updated to include thesomeAppId
parameter, maintaining consistency with the new constructor signature while preserving the original test logic for the error scenario.
235-235
: LGTM: UpdatedXmlConfigFile
usage intestWhenConfigRepositoryHasErrorAndThenRecovered
The
XmlConfigFile
constructor andonRepositoryChange
method calls have been correctly updated to include thesomeAppId
parameter, maintaining consistency with the new signatures while preserving the original test logic for the error recovery scenario.Also applies to: 240-240
126-126
: LGTM: UpdatedXmlConfigFile
usage intestOnRepositoryChange
The
XmlConfigFile
constructor andonRepositoryChange
method calls have been correctly updated to include thesomeAppId
parameter, maintaining consistency with the new signatures while preserving the original test logic for the repository change scenario.Please verify that the
onRepositoryChange
method signature in theXmlConfigFile
class has been updated to include theappId
parameter. Run the following script to check:Also applies to: 143-143
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/YamlConfigFileTest.java (8)
42-42
: LGTM: Addition ofsomeAppId
fieldThe addition of the
someAppId
field is consistent with the changes in theYamlConfigFile
constructor. This is a good practice for declaring test variables that will be reused across multiple test methods.
55-55
: LGTM: Initialization ofsomeAppId
in setUp methodThe initialization of
someAppId
in the setUp method is consistent with the new field addition. This is a good practice for setting up test variables that will be used across multiple test methods.
89-89
: LGTM: Updated YamlConfigFile constructor call intestWhenHasContent
The
YamlConfigFile
constructor call has been correctly updated to include the newsomeAppId
parameter. This change is consistent with the updated constructor signature, and the test logic remains intact.
115-115
: LGTM: Updated YamlConfigFile constructor call intestWhenHasContentWithOrder
The
YamlConfigFile
constructor call has been correctly updated to include the newsomeAppId
parameter. This change is consistent with the updated constructor signature, and the test logic for checking the order of properties remains intact.
129-129
: LGTM: Updated YamlConfigFile constructor call intestWhenHasNoContent
The
YamlConfigFile
constructor call has been correctly updated to include the newsomeAppId
parameter. This change is consistent with the updated constructor signature, and the test logic for checking the behavior when there's no content remains intact.
152-152
: LGTM: Updated YamlConfigFile constructor call intestWhenInvalidYamlContent
The
YamlConfigFile
constructor call has been correctly updated to include the newsomeAppId
parameter. This change is consistent with the updated constructor signature, and the test logic for handling invalid YAML content remains intact.
171-171
: LGTM: Updated YamlConfigFile constructor and onRepositoryChange callsThe
YamlConfigFile
constructor calls have been correctly updated to include the newsomeAppId
parameter in thetestWhenConfigRepositoryHasError
,testOnRepositoryChange
, andtestWhenConfigRepositoryHasErrorAndThenRecovered
methods. Additionally, theonRepositoryChange
method call has been updated to includesomeAppId
. These changes are consistent with the updates in theYamlConfigFile
class, and the test logic remains intact in all cases.Also applies to: 203-203, 215-215, 238-238, 245-245
Line range hint
1-252
: Overall assessment: Changes are consistent and well-implementedThe modifications to
YamlConfigFileTest
consistently update allYamlConfigFile
constructor calls to include the newsomeAppId
parameter. TheonRepositoryChange
method call has also been correctly updated. These changes align with the newappId
parameter implementation in theYamlConfigFile
class.The test logic remains intact across all methods, ensuring that the existing functionality is still properly tested while accommodating the new
appId
parameter. This update maintains the integrity of the test suite and provides coverage for the new feature.No issues or potential problems were identified during this review. The changes appear to be well-implemented and ready for integration.
apollo-mockserver/src/main/java/com/ctrip/framework/apollo/mockserver/ApolloTestingServer.java (1)
55-55
:⚠️ Potential issueConsider making
someAppId
configurableThe
someAppId
variable is currently hardcoded with a static value. For better flexibility and to accommodate different testing scenarios, consider making this value configurable. This could be achieved through environment variables, system properties, or a configuration file.Example implementation:
private static String someAppId = System.getProperty("apollo.mock.appId", "someAppId");This approach allows setting a custom
appId
via system property while maintaining a default value.apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java (3)
20-20
: LGTM: Import statement for ApolloClientSystemConsts added.The addition of this import is consistent with the PR objective of adding support for multiple app IDs. It allows the use of system constants related to the Apollo client in this test class.
145-145
: LGTM: App ID system property cleared in tearDown method.This addition ensures proper cleanup after each test by clearing the APP_ID system property. It prevents potential side effects between tests and is consistent with the addition in the setUp method.
121-121
: LGTM: App ID system property set in setUp method.This addition ensures that the app ID is correctly set for the integration tests, which is in line with the PR objective of supporting multiple app IDs.
To ensure proper cleanup, let's verify that this property is cleared in the tearDown method:
✅ Verification successful
Verified: APP_ID system property is cleared in the tearDown method.
The tearDown method correctly clears the APP_ID system property, ensuring no side effects for other tests.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify APP_ID system property is cleared in tearDown method rg --type java "System\.clearProperty\(ApolloClientSystemConsts\.APP_ID\)" apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.javaLength of output: 215
apollo-core/src/main/java/com/ctrip/framework/foundation/internals/provider/DefaultApplicationProvider.java (1)
120-126
: Approve implementation with suggestions for improvementThe new
getAccessKeySecret(String appId)
method successfully implements support for multiple app IDs, aligning with the PR objectives. However, there are a few areas for improvement:
Consider adding error handling or logging when the property is not found. Returning an empty string silently could lead to difficult-to-debug issues.
It's advisable to validate the input
appId
to prevent potential security issues.Other parts of the system that deal with access key secrets might need to be updated to utilize this new method.
Here's a suggested implementation addressing these points:
@Override public String getAccessKeySecret(String appId) { if (appId == null || appId.trim().isEmpty()) { throw new IllegalArgumentException("appId must not be null or empty"); } if (Objects.equals(appId, m_appId)) { return getAccessKeySecret(); } String key = "apollo.accesskey." + appId + ".secret"; String secret = System.getProperty(key); if (secret == null || secret.isEmpty()) { logger.warn("Access key secret not found for appId: {}", appId); } return secret != null ? secret : ""; }This implementation includes input validation, logging, and maintains the current behavior of returning an empty string if the property is not found.
To ensure this change doesn't break existing functionality and is properly utilized, you may want to run the following verification:
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XMLConfigAnnotationTest.java (8)
53-54
: LGTM: Addition ofsomeAppId
constantThe addition of the
someAppId
constant is in line with the PR objective of supporting multiple app IDs. The constant is correctly defined as private and final, following good Java practices.
60-61
: LGTM: UpdatedmockConfig
calls intestApolloConfig
The
mockConfig
calls have been correctly updated to include thesomeAppId
parameter. This change aligns with the PR objective of supporting multiple app IDs and ensures that the test cases now consider the app ID when mocking configurations.
74-74
: LGTM: UpdatedmockConfig
call intestApolloConfigWithWrongFieldType
The
mockConfig
call has been correctly updated to include thesomeAppId
parameter, maintaining consistency with the PR objective and previous changes.
84-85
: LGTM: UpdatedmockConfig
calls intestApolloConfigChangeListener
The
mockConfig
calls have been correctly updated to include thesomeAppId
parameter. These changes maintain consistency with the PR objective and previous modifications while preserving the original test logic.
139-139
: LGTM: UpdatedmockConfig
call intestApolloConfigChangeListenerWithWrongParamType
The
mockConfig
call has been correctly updated to include thesomeAppId
parameter, maintaining consistency with the PR objective and previous changes. The test's purpose and expected behavior remain intact.
148-148
: LGTM: UpdatedmockConfig
call intestApolloConfigChangeListenerWithWrongParamCount
The
mockConfig
call has been correctly updated to include thesomeAppId
parameter, maintaining consistency with the PR objective and previous changes. The test's purpose and expected behavior remain intact.
158-159
: LGTM: UpdatedmockConfig
calls intestApolloConfigChangeListenerWithInterestedKeys
The
mockConfig
calls have been correctly updated to include thesomeAppId
parameter. These changes maintain consistency with the PR objective and previous modifications while preserving the original test logic and assertions.
Line range hint
1-300
: Summary: Successful implementation of multiple app ID support in XMLConfigAnnotationTestThe changes in this file consistently implement support for multiple app IDs across all relevant test methods. The modifications are minimal and focused, aligning well with the PR objective. The addition of the
someAppId
constant and its usage in allmockConfig
calls ensures that the tests now consider app-specific configurations.These changes enhance the test coverage for the new multiple app ID feature without altering the existing test logic or expected outcomes. This approach minimizes the risk of introducing unintended side effects while ensuring that the new functionality is properly tested.
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.java (3)
62-64
: LGTM: Initialization ofsomeAppId
The addition of
someAppId
initialization is consistent with the PR objective of adding support for multiple app IDs. This change provides a test value for the new app ID parameter used throughout the test class.
216-216
: LGTM: Update tocheckNamespaceName
methodThe change correctly reflects the updated method signature of
trimNamespaceFormat
to include thesomeAppId
parameter. This is consistent with the PR objective of supporting multiple app IDs.
191-204
: Clarification needed: Purpose ofappIdAndNamespace
wrapperThe
appIdAndNamespace
wrapper has been introduced in thecheckNamespaceName
method calls. However, the current implementation ofappIdAndNamespace
simply returns the namespace unchanged.Could you please clarify the purpose of this wrapper? Is it a placeholder for future functionality related to app ID and namespace combination? If so, consider adding a TODO comment to explain the intended future use.
✅ Verification successful
Verification Successful:
appIdAndNamespace
Usage ConfirmedThe
appIdAndNamespace
method is defined and used solely withinDefaultConfigFactoryTest.java
as observed. There are no TODO comments or indications of it being a placeholder for future functionality.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if there are any TODO comments related to appIdAndNamespace grep -n "TODO.*appIdAndNamespace" apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryTest.javaLength of output: 124
Script:
#!/bin/bash # Find the implementation of appIdAndNamespace rg 'appIdAndNamespace\s*\(' .Length of output: 2534
Script:
#!/bin/bash # List all usages of appIdAndNamespace rg 'appIdAndNamespace' .Length of output: 2527
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/BootstrapConfigTest.java (11)
60-61
: LGTM: Addition ofsomeAppId
constantThe addition of the
someAppId
constant is appropriate for testing purposes. It's correctly defined as private and static, which aligns with best practices for test constants.
140-141
: LGTM: Consistent use ofsomeAppId
inmockConfig
callsThe modifications to include
someAppId
in bothmockConfig
calls are consistent with the earlier changes. This approach correctly uses the same app ID for different namespaces, which aligns with the expected behavior in a multi-namespace configuration scenario.
179-180
: LGTM: Consistent use ofsomeAppId
inmockConfig
callsThe modifications to include
someAppId
in bothmockConfig
calls are consistent with the earlier changes. This approach correctly uses the same app ID for different namespaces, maintaining consistency with the pattern observed in other test classes.
218-218
: LGTM: UpdatedmockConfig
call withsomeAppId
The modification to include
someAppId
in themockConfig
call is consistent with the earlier changes. This update maintains consistency across different test scenarios, ensuring that the app ID is properly used in all relevant test cases.
250-250
: LGTM: Consistent use ofsomeAppId
inprepareYamlConfigFile
callThe modification to include
someAppId
in theprepareYamlConfigFile
call is consistent with the earlier changes. This update maintains consistency across different test scenarios that use YAML configuration files, ensuring that the app ID is properly used in all relevant test cases.
284-284
: LGTM: UpdatedmockConfig
call withsomeAppId
The modification to include
someAppId
in themockConfig
call is consistent with the earlier changes. This update maintains consistency across different test scenarios, including cases where conditional properties are turned off, ensuring that the app ID is properly used in all relevant test cases.
317-317
: LGTM: Consistent use ofsomeAppId
inprepareYamlConfigFile
callThe modification to include
someAppId
in theprepareYamlConfigFile
call is consistent with the earlier changes. This update maintains consistency across different test scenarios that use YAML configuration files, including cases where conditional properties are turned off, ensuring that the app ID is properly used in all relevant test cases.
353-353
: LGTM: UpdatedmockConfig
call withsomeAppId
The modification to include
someAppId
in themockConfig
call is consistent with the earlier changes. This update maintains consistency across different test scenarios, including cases where bootstrap is disabled, ensuring that the app ID is properly used in all relevant test cases.
176-176
: LGTM: UpdatedprepareYamlConfigFile
call withsomeAppId
The modification to include
someAppId
in theprepareYamlConfigFile
call is consistent with the earlier changes. This update suggests that theprepareYamlConfigFile
method signature has been modified to include an app ID parameter.To ensure consistency across the codebase, let's verify the
prepareYamlConfigFile
method signature:#!/bin/bash # Search for the prepareYamlConfigFile method definition rg --type java "static void prepareYamlConfigFile\(" apollo-client/src/test/java/
406-406
: LGTM with suggestions: UpdatedmockConfig
call and method signaturesThe modifications in this test class are consistent with earlier changes:
- The
mockConfig
call now includessomeAppId
, maintaining consistency with other test classes.- The
beforeClass
andafterClass
method signatures have been updated to include exception clauses.These changes suggest that the methods may now throw exceptions due to modifications in their implementation or the methods they call.
To ensure these changes are justified, let's verify the implementations of
beforeClass
andafterClass
:Please review the results to confirm that the exception handling is necessary and appropriate.
Also applies to: 414-414, 418-418
96-96
: LGTM: UpdatedmockConfig
call withsomeAppId
The modification to include
someAppId
in themockConfig
call is consistent with the earlier addition of the constant. This change suggests an update to themockConfig
method signature to include an app ID parameter.To ensure consistency across the codebase, let's verify the
mockConfig
method signature:✅ Verification successful
Verified:
mockConfig
method signature includessomeAppId
All usages of the
mockConfig
method correctly include thesomeAppId
parameter, and the method signature has been appropriately updated.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the mockConfig method definition rg --type java "static void mockConfig\(" apollo-client/src/test/java/Length of output: 83
Script:
#!/bin/bash # Search for all definitions of the mockConfig method across the entire codebase rg --type java "\\bmockConfig\\s*\\(" .Length of output: 16559
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java (4)
131-131
: LGTM: Initialization ofsomeAppId
.The addition of
someAppId
initialization in thesetUp
method is consistent with the changes to support multiple app IDs. This change looks good and necessary for the updated test scenarios.
268-268
: LGTM: Updated verify method call for RepositoryChangeListener.The verify method call for the RepositoryChangeListener has been correctly updated to include
someAppId
. This change ensures that the correct app ID is being verified in the test, which is consistent with the updates to support multiple app IDs.Also applies to: 317-317
Line range hint
1-468
: Overall assessment: Well-implemented changes for multi-app ID support.The changes made to
RemoteConfigRepositoryTest.java
consistently implement support for multiple app IDs across various test methods and utility classes. The modifications are necessary and align well with the goal of enhancing the configuration capabilities to handle multiple app IDs.Key points:
- RemoteConfigRepository constructor calls have been updated consistently.
- Verification methods have been adjusted to include app ID checks.
- A new method for app-specific access key secrets has been added.
The suggested improvements, if implemented, would further enhance the code quality and test robustness. Great job on maintaining consistency throughout the changes!
42-42
: 💡 Codebase verificationUnnecessary import detected.
The
PropertySourcesProcessor
import is present but not used in theRemoteConfigRepositoryTest.java
file. Please remove this unused import to clean up the codebase.🔗 Analysis chain
Verify the necessity of the new import.
The
PropertySourcesProcessor
import has been added, but it doesn't appear to be used in the visible code. Please ensure this import is necessary for the test class, or remove it if unused.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usage of PropertySourcesProcessor in the test file rg --type java "PropertySourcesProcessor" apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.javaLength of output: 212
⛔ Skipped due to learnings
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java:64-64 Timestamp: 2024-10-01T03:05:09.661Z Learning: In the `PropertySourcesProcessor` class, the `APP_NAMESPACE_NAMES` map and its inner `Multimap` instances do not need to be thread-safe because concurrent access is not expected.
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java:64-64 Timestamp: 2024-10-08T15:31:24.844Z Learning: In the `PropertySourcesProcessor` class, the `APP_NAMESPACE_NAMES` map and its inner `Multimap` instances do not need to be thread-safe because concurrent access is not expected.
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/XmlConfigPlaceholderAutoUpdateTest.java (7)
44-45
: LGTM: Addition ofsomeAppId
constantThe introduction of the
someAppId
constant aligns with the PR objective of adding support for multiple app IDs. Using a constant instead of hardcoding the value improves code maintainability.
56-56
: LGTM: Consistent use ofsomeAppId
intestAutoUpdateWithOneNamespace
The changes in this method consistently apply the new
someAppId
parameter to bothprepareConfig
andonRepositoryChange
method calls. This modification aligns with the PR objective of supporting multiple app IDs.Also applies to: 68-68
91-91
: LGTM: Consistent use ofsomeAppId
intestAutoUpdateDisabled
The changes in this method consistently apply the new
someAppId
parameter to bothprepareConfig
andonRepositoryChange
method calls. This modification aligns with the PR objective of supporting multiple app IDs.Also applies to: 103-103
123-125
: LGTM: Consistent use ofsomeAppId
intestAutoUpdateWithMultipleNamespaces
The changes in this method consistently apply the new
someAppId
parameter toprepareConfig
method calls for both application and FX Apollo configs. This modification aligns with the PR objective of supporting multiple app IDs across multiple namespaces.
168-169
: LGTM: Consistent use ofsomeAppId
intestAutoUpdateWithMultipleNamespacesWithSameProperties
The changes in this method consistently apply the new
someAppId
parameter toprepareConfig
method calls for both application and FX Apollo configs, as well as theonRepositoryChange
method call. This modification aligns with the PR objective of supporting multiple app IDs across multiple namespaces and repository change events.Also applies to: 181-181
198-198
: LGTM: Consistent use ofsomeAppId
across all test methodsThe changes consistently apply the new
someAppId
parameter to allprepareConfig
andonRepositoryChange
method calls across the remaining test methods. This modification aligns with the PR objective of supporting multiple app IDs and ensures consistency throughout the test suite.Also applies to: 212-212, 233-233, 247-247, 263-263, 274-274, 293-295, 323-323, 334-334, 352-352, 364-364, 382-382, 394-394, 413-413, 425-425, 472-472, 501-501
Line range hint
1-624
: Summary: Successful implementation of multiple app ID support in test suiteThe changes in this file consistently implement support for multiple app IDs across all test methods. The introduction of the
someAppId
constant and its usage inprepareConfig
andonRepositoryChange
method calls align with the PR objective. These modifications enhance the test suite's capability to verify the multi-app ID feature without altering the existing test logic or structure.Some observations:
- The changes are consistent across all test methods.
- The existing test logic remains intact, ensuring that previous functionality is still covered.
- The modifications provide a foundation for potential future tests specific to multi-app ID scenarios.
Overall, these changes effectively adapt the test suite to support the new multiple app ID feature.
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (6)
87-89
: LGTM: Improved test setup.The initialization of
someAppId
andsomeCluster
in thesetUp
method is a good practice. It centralizes the setup and ensures consistency across all test methods.
193-193
: LGTM: Consistent update of method call signature.The
submit
method call has been correctly updated to includesomeAppId
as the first parameter, maintaining consistency with other test methods.
255-256
: LGTM: Updated method call, but verify timeout change.The
submit
method call has been correctly updated to includesomeAppId
as the first parameter, consistent with other test methods.However, the timeout for
onNotified.get()
has been increased from 5000 to 50000 milliseconds. This significant increase might indicate that the test was failing due to timing issues. Please verify if this change is necessary and consider adding a comment explaining the reason for the increased timeout.
326-326
: LGTM: Consistent updates to method call signatures.Both
submit
method calls have been correctly updated to includesomeAppId
as the first parameter, maintaining consistency with other test methods.Also applies to: 329-329
587-593
: LGTM: New method added, but verify null return behavior.The new
getAccessKeySecret(String appId)
method has been correctly implemented to returnsomeSecret
when the providedappId
matchessomeAppId
. This addition supports app-specific access key secrets, which is consistent with the test setup.However, please verify if returning null for other appIds is the intended behavior in the main implementation. Consider adding a comment explaining this behavior or throwing an exception for unknown appIds if that's more appropriate.
142-142
: LGTM: Updated method call signature.The
submit
method call has been correctly updated to includesomeAppId
as the first parameter, consistent with changes in other test methods. This reflects an update in theRemoteConfigLongPollService.submit
method signature.✅ Verification successful
Further Verification Required: 'submit' method not found in the specified location.
The previous search did not locate the
submit
method inRemoteConfigLongPollService.java
. Please run the following script to search for all implementations of thesubmit
method across the codebase to verify its signature and location.
Further Verification Needed: Adjusting search pattern for
submit
method.The previous search did not locate the
submit
method with the specified signature. Please run the following script to search for all implementations of thesubmit
method across the codebase with a more flexible pattern to identify its exact signature and location.
Further Verification Required: Unable to locate
submit
method with existing patterns.The previous searches did not locate the
submit
method inRemoteConfigLongPollService.java
with the specified patterns. Please run the following script to perform a more flexible search for thesubmit
method across the entire Java codebase, disregarding return types and parameter counts.
Further Verification Needed: Unable to locate
submit
method with previous search patterns.The previous searches did not find the
submit
method inRemoteConfigLongPollService.java
using the specified patterns. Please run the following script to perform a broader search for thesubmit
method across the entire Java codebase to identify its signature and location.
Verified:
submit
method signature matches correctly.The
submit
method inRemoteConfigLongPollService.java
exists with the signaturepublic boolean submit(String appId, String namespace, RemoteConfigRepository remoteConfigRepository)
. The test invocation correctly matches this signature.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check the signature of the submit method in RemoteConfigLongPollService rg --type java "public.*submit\(" apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.javaLength of output: 187
Script:
#!/bin/bash # Search for all 'submit' method declarations in the Java codebase using ast-grep ast-grep --lang java --pattern $'public void submit($_, $_, $_) { $$$ }' .Length of output: 75
Script:
#!/bin/bash # Search for all 'submit' method declarations in the Java codebase using ast-grep with a flexible pattern ast-grep --lang java --pattern $'public $_ submit($_, $_, $_) { $$$ }' .Length of output: 73
Script:
#!/bin/bash # Search for all 'submit' method declarations in the Java codebase using ast-grep with a highly flexible pattern ast-grep --lang java --pattern $'public $_ submit($_) { $$$ }' .Length of output: 65
Script:
#!/bin/bash # Broad search for 'submit' method declarations in Java codebase using ripgrep with context rg --type java "submit\(" --context 2 .Length of output: 10082
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderTest.java (11)
63-63
: LGTM: New constant for app ID.The addition of the
someAppId
constant is a good practice. It centralizes the app ID value used in tests, making it easier to maintain and update if needed.
74-74
: LGTM: Updated mock configuration with app ID.The inclusion of
someAppId
in themockConfig
call ensures that the test correctly simulates an environment with a specific app ID, improving the test's accuracy.
82-82
: LGTM: Consistent use of app ID in mock configuration.The addition of
someAppId
to themockConfig
call maintains consistency with other tests and accurately represents a scenario with a specific app ID but no configuration.
95-95
: LGTM: App ID added to application property source test.The inclusion of
someAppId
in this test ensures consistency across different property source scenarios and improves the test's relevance to real-world configurations.
111-111
: LGTM: App ID added to properties-compatible config file test.The addition of
someAppId
to themockConfigFile
call ensures that the test for properties-compatible sources also considers the app ID, maintaining consistency across different configuration types.
127-127
: LGTM: Consistent app ID usage in non-normalized case test.The addition of
someAppId
to this test case maintains consistency and ensures that the app ID is considered even when testing non-normalized property names.
139-143
: LGTM: App ID consistently applied to multiple property sources.The addition of
someAppId
to bothmockConfig
calls ensures that the test accurately represents a scenario where multiple property sources are used for the same application. This change improves the test's relevance to real-world multi-source configurations.
161-165
: LGTM: App ID consistently applied in multiple properties-compatible sources test.The addition of
someAppId
to bothmockConfigFile
andmockConfig
calls ensures that the test accurately represents scenarios with multiple properties-compatible sources for the same application. This change improves the test's comprehensiveness.
180-184
: LGTM: App ID consistently applied in overlapping property sources test.The addition of
someAppId
to bothmockConfig
calls ensures that the test accurately represents scenarios where multiple property sources with overlapping properties are used for the same application. This change enhances the test's relevance to complex configuration scenarios.
199-203
: LGTM: App ID consistently applied in mixed property sources test.The addition of
someAppId
to bothmockConfig
calls ensures that the test accurately represents scenarios with multiple property sources, including properties-compatible sources, for the same application. This change improves the test's coverage of diverse configuration scenarios.
Line range hint
217-436
: LGTM: Consistent application of app ID across all test methods.The addition of
someAppId
to all remainingmockConfig
andmockConfigFile
calls ensures consistency across the entire test suite. This change:
- Improves the accuracy of test simulations by consistently representing a specific application context.
- Enhances the test suite's ability to catch potential issues related to app-specific configurations.
- Makes the tests more representative of real-world scenarios where each configuration is associated with a specific app ID.
These modifications collectively strengthen the test suite and improve its reliability in validating the Apollo client's behavior across various configuration scenarios.
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigPlaceholderAutoUpdateTest.java (9)
55-55
: New constantsomeAppId
addedA new constant
someAppId
has been introduced. This is a good practice for maintaining consistency across the test class.
74-74
: Improved flexibility intestAutoUpdateWithOneNamespace
The use of
someAppId
instead ofConfigConsts.NAMESPACE_APPLICATION
in theprepareConfig
method call enhances the test's flexibility. This change allows for easier testing with different app IDs.
101-102
: Consistent use ofsomeAppId
intestAutoUpdateWithOneYamlFile
The
prepareYamlConfigFile
method now usessomeAppId
, maintaining consistency with the changes in other methods. This improves the overall coherence of the test class.
129-129
: Consistent use ofsomeAppId
intestAutoUpdateWithValueAndXmlProperty
The
prepareConfig
method now usessomeAppId
, maintaining consistency with the changes in other methods. This enhances the uniformity of the test class.
161-162
: Consistent use ofsomeAppId
intestAutoUpdateWithYamlFileWithValueAndXmlProperty
The
prepareYamlConfigFile
method now usessomeAppId
, aligning with the changes in other methods. This maintains the consistency of the test class.
199-199
: Consistent use ofsomeAppId
intestAutoUpdateDisabled
The
prepareConfig
method now usessomeAppId
, maintaining consistency with the changes in other methods. This enhances the overall coherence of the test class.
229-230
: Consistent use ofsomeAppId
and new pattern intestAutoUpdateWithMultipleNamespaces
The
prepareConfig
methods now usesomeAppId
, maintaining consistency with other methods. Additionally,someAppId
is now included in theonRepositoryChange
method call, which is a new pattern. This change enhances the test's ability to simulate multi-app scenarios more accurately.Also applies to: 241-241
270-271
: Consistent use ofsomeAppId
intestAutoUpdateWithMultipleNamespacesWithSameProperties
The
prepareConfig
methods andonRepositoryChange
call now usesomeAppId
, maintaining consistency with the changes in the previous method. This uniform approach enhances the readability and maintainability of the test class.Also applies to: 283-283
298-303
: Consistent implementation ofsomeAppId
throughout the test classThe changes across the entire file demonstrate a consistent approach to using the newly introduced
someAppId
constant. This refactoring improves the test class in several ways:
- Increased flexibility: Tests can now be easily configured for different app IDs without modifying multiple locations.
- Better maintainability: Using a constant instead of hardcoded strings reduces the risk of typos and makes future changes easier.
- Improved readability: The consistent use of
someAppId
makes the purpose of the value clearer throughout the tests.These changes align well with best practices for writing maintainable and flexible test code.
Also applies to: 328-328, 340-340, 354-354, 385-385, 397-397, 413-413, 424-424, 437-437, 447-447, 465-466, 494-494, 523-523, 549-549, 577-577, 608-608, 639-639, 670-670, 702-702, 730-730, 759-759, 794-794, 859-859, 894-894, 920-920, 933-933, 947-947, 960-960, 974-974, 987-987
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistry.java (1)
58-59
: Verify consistency ingetFactory
method usageSimilarly, the
getFactory(String namespace)
method now callsgetFactory(String appId, String namespace)
. Confirm that all usages ofgetFactory
are consistent with this change and that theappId
is appropriately managed in different contexts.To identify all invocations of the
getFactory
method with a single parameter, run:✅ Verification successful
getFactory
Method Usage is ConsistentAll usages of
getFactory
have been updated to include theappId
parameter where necessary. The existing single-parameter usages are confined to test files and align with the current implementation.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Locate all calls to `getFactory` with one argument. # Search for invocations of `getFactory` with one parameter rg --type java 'getFactory\s*\(\s*[^,]+\s*\)'Length of output: 2552
Script:
#!/bin/bash # Description: Locate all calls to `getFactory` with one argument. # Search for invocations of `getFactory` with one parameter rg --type java 'getFactory\s*\(\s*[^,]+\s*\)'Length of output: 2435
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (4)
35-35
: Approved: Addedm_configUtil
member variableThe addition of
m_configUtil
is appropriate for accessing configuration utilities such as theappId
. This enhances the flexibility of the configuration management.
44-44
: Ensure correctappId
is used when obtaining factoryThe
getFactory(String namespace)
method now delegates togetFactory(m_configUtil.getAppId(), namespace)
. Ensure thatm_configUtil.getAppId()
returns the intendedappId
, especially in environments where multipleappId
s are supported simultaneously.
73-73
: Ensure thread-safe access when updatingm_factories
When adding entries to
m_factories
, thread safety must be considered due to the use ofHashBasedTable
. This is related to the earlier concern about thread safety.Refer to the previous comment on line 33 regarding making
m_factories
thread-safe.
50-50
:⚠️ Potential issueVerify
ConfigRegistry
supportsappId
parameter ingetFactory
methodConfirm that the
ConfigRegistry
class has been updated to include thegetFactory(String appId, String namespace)
method. If not, this call may result in a compilation error or runtime issues.Run the following script to verify if the
ConfigRegistry
class includes the new method signature:apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (1)
82-84
: Addition of overloadedgetConfig
method aligns with PR objectivesThe new method
getConfig(String appId, String namespace)
extends the functionality to support multiple app IDs, enhancing configuration retrieval capabilities as per the PR objectives.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (5)
42-42
: Addition ofm_appId
field to support multiple application IDsThe introduction of the
m_appId
field appropriately allows theSimpleConfig
class to handle configurations specific to different application IDs.
55-56
: Preserving the original constructor for backward compatibilityThe original constructor is retained and now delegates to the new constructor using
this(null, namespace, configRepository);
, ensuring backward compatibility with existing code.
65-69
: New constructor facilitates configurableappId
with fallbackAdding a new constructor that accepts
appId
enhances flexibility. The fallback toConfigUtil.getAppId()
whenappId
isnull
ensures seamless integration for cases whereappId
is not explicitly provided.
114-115
: OverloadingonRepositoryChange
to includeappId
The overloaded
onRepositoryChange
method with theappId
parameter correctly expands functionality to handle repository changes for multiple application IDs.
Line range hint
125-137
: Verify thatcalcPropertyChanges
andfireConfigChange
methods accept theappId
parameterTo ensure that the methods
calcPropertyChanges
andfireConfigChange
have been updated appropriately to accept the newappId
parameter, please run the following script:apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManagerTest.java (1)
151-155
: Clarify method behavior inSomeConfigFactory
andAnotherConfigFactory
.The overridden methods with the
appId
parameter inSomeConfigFactory
andAnotherConfigFactory
currently returnnull
. If these factories are supposed to provide configuration objects based onappId
andnamespace
, consider implementing them to return appropriate mock configurations or explain why returningnull
is acceptable in this context.Also applies to: 160-164, 173-177, 182-186
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigManagerTest.java (2)
46-46
: Initialization ofsomeAppId
in Test SetupThe addition of the
someAppId
variable and its initialization in thesetUp
method is appropriate. It prepares the test environment for multi-app ID support and aligns with the PR's objectives.Also applies to: 54-54
Line range hint
116-180
: Proper Implementation of Multi-App ID Support with Backward CompatibilityThe updates to include the
appId
parameter in the method signatures ofgetFactory
,create
, andcreateConfigFile
enhance configurability for multiple app IDs. The inclusion of overloaded methods without theappId
parameter that default tosomeAppId
ensures backward compatibility with existing code. This approach maintains existing functionality while extending support for the new feature.apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (1)
95-96
: Ensure consistency in method delegation forcreateConfigFile
The method
createConfigFile(String namespace, ConfigFileFormat configFileFormat)
delegates tocreateConfigFile
withappId
. This pattern maintains consistency and centralized handling ofappId
. Good practice!apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (5)
23-37
: Imports Updated Appropriately for New FunctionalityThe added import statements for
ConfigConsts
,Maps
,Multimaps
, andMap
are necessary for the introduced changes and ensure that all utilized classes and interfaces are properly referenced.Also applies to: 48-51
65-65
: Effective Management of Namespaces withAPP_NAMESPACE_NAMES
MapThe introduction of
APP_NAMESPACE_NAMES
as aMap<Integer, Multimap<String, String>>
enhances the management of namespaces by associating them with both their order andappId
. This structure supports multiple applications and maintains the necessary mapping efficiently.
75-76
: Refactoring for Enhanced Flexibility inaddNamespaces
MethodBy altering the existing
addNamespaces(Collection<String> namespaces, int order)
method to delegate to the overloaded version that includesappId
, you promote code reuse and support the addition of multipleappId
s seamlessly.
107-123
: Correct Implementation of Namespace Initialization for Multiple App IDsThe revised logic in the
initializePropertySources
method accurately iterates through each order,appId
, and namespace. This ensures that configurations are correctly loaded for each application and namespace combination, aligning with the PR's objective to support multipleappId
s.
127-127
: Proper Clearing ofAPP_NAMESPACE_NAMES
to Prevent Memory LeaksClearing
APP_NAMESPACE_NAMES
after initialization and within thereset
method is appropriate. It ensures that no residual data persists unnecessarily, which could lead to memory leaks in long-running applications.Also applies to: 179-179
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (1)
122-130
:⚠️ Potential issueInconsistent Namespace Usage in
prepareYamlConfigFile
MethodSimilar to
prepareConfig
, theprepareYamlConfigFile
method might be misusing the namespace when initializingYamlConfigFile
. Ensure that the correct namespace is used to prevent unexpected behavior.Update the
YamlConfigFile
initialization to match the providednamespaceNameWithFormat
:protected static YamlConfigFile prepareYamlConfigFile(String appId, String namespaceNameWithFormat, Properties properties) { ConfigRepository configRepository = mock(ConfigRepository.class); when(configRepository.getConfig()).thenReturn(properties); // spy it for testing after - YamlConfigFile configFile = spy(new YamlConfigFile(appId, namespaceNameWithFormat, configRepository)); + YamlConfigFile configFile = spy(new YamlConfigFile(appId, namespaceNameWithFormat, configRepository)); mockConfigFile(appId, namespaceNameWithFormat, configFile); return configFile; }Ensure that any discrepancies between the namespace used in
YamlConfigFile
and the one registered inmockConfigFile
are resolved.Likely invalid or redundant comment.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (1)
297-300
: Sanitize inputs when constructing file namesWhen assembling the local cache file name using
appId
,cluster
, andnamespace
, ensure that these values do not contain characters that are invalid or unsafe for file names (e.g., slashes, colons). Consider sanitizing these inputs to prevent file system errors or security issues when reading from or writing to the file system.apollo-client/src/main/java/com/ctrip/framework/apollo/spring/annotation/ApolloAnnotationProcessor.java (2)
109-113
: Maintain backward compatibility with existing configurationsBy introducing
appId
into the configuration retrieval process, ensure that existing functionality remains unaffected. Configurations that do not specify anappId
should continue to work as before. Testing the changes against existing use cases can help verify backward compatibility.
109-113
:⚠️ Potential issueVerify the existence and usage of
ConfigService.getConfig(String appId, String namespace)
The updated code introduces a call to
ConfigService.getConfig(resolvedAppId, resolvedNamespace)
. Please ensure that theConfigService
class has a methodgetConfig(String appId, String namespace)
implemented. If this method is newly added, make sure it's properly defined and all relevant classes are updated to support multipleappId
s.To confirm the method's existence and usage, you can run the following script:
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (4)
68-70
: Constructor Delegation Maintains Backward CompatibilityThe default constructor now delegates to the new constructor by passing
null
as theappId
, which ensures backward compatibility while introducing support for multipleappId
s.
78-84
: Proper Initialization ofm_appId
and Resource LoadingThe new constructor correctly initializes
m_appId
. IfappId
isnull
, it defaults to the value fromConfigUtil
, maintaining the existing behavior. The loading of resource properties with the updatedappId
andnamespace
parameters ensures that configurations are appropriately fetched for each application.
240-241
: OverloadedonRepositoryChange
Method Enhances FlexibilityThe addition of the overloaded
onRepositoryChange
method that includesappId
allows the configuration to respond to repository changes specific to different applications, enhancing flexibility in handling multipleappId
s.
325-335
: Resource Loading Logic Preserves Backward CompatibilityThe
loadFromResource
method first attempts to load the resource using theappId+namespace
format. If the resource is not found and the providedappId
matches the defaultappId
, it falls back to loading the resource using just thenamespace
. This logic ensures that existing configurations without anappId
prefix continue to work after the update, preserving backward compatibility.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5)
75-75
: Addition ofm_appId
field is appropriateThe field
m_appId
is correctly declared asprivate final String
and follows the existing naming conventions.
191-194
: Consistency in usingm_appId
Using
this.m_appId
to retrieve theappId
ensures consistency throughout the class.
336-336
:⚠️ Potential issueConfirm
submit
method inremoteConfigLongPollService
acceptsappId
Verify that the
submit
method ofremoteConfigLongPollService
has been updated to acceptappId
as its first parameter. If not, this may cause runtime or compilation issues.Run the following script to check the
submit
method signature:#!/bin/bash # Find the submit method in RemoteConfigLongPollService rg --type java 'void submit\(String appId,.*String namespace,.*RemoteConfigRepository repository\)'
96-96
: Ensure all instantiations ofRemoteConfigRepository
are updatedWith the addition of
appId
to the constructor, verify that all places whereRemoteConfigRepository
is instantiated have been updated to include the newappId
parameter.You can use the following script to locate instantiations:
✅ Verification successful
All instantiations of
RemoteConfigRepository
have been updated with theappId
andnamespace
parameters.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Find all instantiations of RemoteConfigRepository rg --type java 'new RemoteConfigRepository\('Length of output: 1813
160-160
:⚠️ Potential issueVerify
fireRepositoryChange
method acceptsappId
parameterEnsure that the
fireRepositoryChange
method has been updated to acceptappId
as an argument. If it hasn't been modified, this call may lead to compilation errors.Use the following script to check the method signature:
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (4)
570-570
: Ensure all invocations ofcalcPropertyChanges
include the newappId
parameterThe method
calcPropertyChanges
now includes anappId
parameter. Please verify that all calls to this method have been updated to include theappId
parameter to prevent any potential issues.Run the following script to find any calls to
calcPropertyChanges
that may not include theappId
parameter:✅ Verification successful
All invocations of
calcPropertyChanges
include the newappId
parameter.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all method calls to `calcPropertyChanges` with three arguments (missing `appId`). ast-grep --lang java --pattern $'calcPropertyChanges($_, $_, $_)'Length of output: 233
Script:
#!/bin/bash # Description: Find all method calls to `calcPropertyChanges` with three arguments (missing `appId`). ast-grep --lang java --pattern $'calcPropertyChanges($_, $_, $_)'Length of output: 66
590-590
: Confirm thatConfigChange
class constructor acceptsappId
as the first parameterIn the instantiations of
ConfigChange
, theappId
is passed as the first argument. Please verify that theConfigChange
class constructor has been updated to accept theappId
parameter and that all usages of this class throughout the codebase have been updated accordingly.Run the following script to check the constructor definition of
ConfigChange
:Also applies to: 595-595, 605-605
457-457
: Ensure all invocations offireConfigChange
include the newappId
parameterThe method signature of
fireConfigChange
has been updated to include anappId
parameter. Please verify that all calls to this method throughout the codebase have been updated to pass the appropriateappId
value to prevent compilation errors or unexpected behavior.Run the following script to find any invocations of
fireConfigChange
that may not have been updated:
465-465
: Verify thatInterestedConfigChangeEvent
constructor supports theappId
parameterIn the line
InterestedConfigChangeEvent(appId, namespace, changes, interestedChangedKeys);
, theInterestedConfigChangeEvent
is instantiated with theappId
parameter. Please ensure that the constructor ofInterestedConfigChangeEvent
has been updated to accept theappId
parameter and that all usages of this class are consistent with this change.Run the following script to verify the constructor definition of
InterestedConfigChangeEvent
:apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (2)
85-89
: Addition ofgetAppId()
method enhances functionalityIntroducing the
getAppId()
method provides necessary access to them_appId
field, enhancing the class's functionality. This addition aligns with best practices for encapsulation and data access.
Line range hint
102-125
: Verify impact of passingappId
toConfigFileChangeEvent
The constructor of
ConfigFileChangeEvent
now includes theappId
. It's important to verify that all usages ofConfigFileChangeEvent
are updated accordingly and that the event handling mechanisms accommodate the new parameter without side effects.Run the following script to check for other usages of
ConfigFileChangeEvent
:✅ Verification successful
Verified: All
ConfigFileChangeEvent
constructor usages are updated correctly.All instances of
ConfigFileChangeEvent
have been updated to include theappId
parameter. No other usages without the new parameter were found.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all instantiations of ConfigFileChangeEvent and verify constructor parameters. # Test: Search for all 'new ConfigFileChangeEvent' usages. # Expect: Constructor calls should match the updated signature. rg --type java --pcre2 '(new\s+ConfigFileChangeEvent\s*\()' -A 3Length of output: 600
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java (2)
74-74
: Approved: Addition ofsomeAppId
variableThe declaration and initialization of the
someAppId
variable are appropriate and align with the changes to support multiple app IDs.Also applies to: 95-95
150-150
: Skip: Past review comments are still applicableThe updates to the
DefaultConfig
constructor calls have been previously reviewed and the comments are still valid.Also applies to: 183-183, 202-202, 225-225, 256-256, 288-288, 323-323, 346-346, 369-369, 392-392, 415-415, 438-438, 461-461, 485-485, 521-521, 547-547, 577-577, 596-596, 614-614, 652-652, 719-719, 745-745, 805-805, 840-840, 867-867, 880-880, 900-900, 926-926
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java (5)
116-117
: Consistent Use ofsomeAppId
in Mock ConfigurationsThe
mockConfig
method calls have been updated to usesomeAppId
as theappId
, improving consistency across the tests. Ensure that all instances wheremockConfig
is called are updated accordingly to avoid any discrepancies in the test configurations.Also applies to: 135-135, 145-147, 161-161, 164-164, 176-176, 185-185, 197-198, 212-213, 266-266, 275-275, 285-286, 342-343, 374-374, 400-404, 407-407, 464-467, 470-471, 495-501, 520-526, 541-546, 565-568, 580-580, 586-589, 596-600, 609-618, 627-627, 641-646
653-678
: New Test MethodtestApolloMultipleConfig
VerifiedThe new test method
testApolloMultipleConfig
effectively validates the functionality of multiple configurations with differentappId
s. The setup of mocked configurations and assertions appears correct.
1111-1112
: Consistency in@ApolloConfig
AnnotationsIn the
TestApolloConfigBean5
class, the@ApolloConfig
annotation on themultipleConfig
field specifies bothappId
andvalue
. Ensure that this matches the expected annotation parameters and that the configuration is correctly injected.
1097-1106
: Correct Usage of@MultipleConfig
AnnotationThe
@EnableApolloConfig
annotation now includes themultipleConfigs
attribute, utilizing the@MultipleConfig
annotation to specify additionalappId
s and namespaces. Verify that this usage aligns with the framework's implementation of multiple configurations.#!/bin/bash # Description: Check the definition of `EnableApolloConfig` to confirm it supports `multipleConfigs`. # Test: Search for the `EnableApolloConfig` annotation definition. rg '@interface EnableApolloConfig' -A 20 # Expected Result: The `EnableApolloConfig` definition should include the `multipleConfigs` attribute.
661-664
: Verify Namespace Loading for MultipleappId
sEnsure that the namespaces specified for different
appId
s are correctly loaded and that there are no conflicts or overlaps between them. This is critical when supporting multiple applications.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java
Show resolved
Hide resolved
apollo-core/src/main/java/com/ctrip/framework/foundation/spi/provider/ApplicationProvider.java
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/spi/DefaultConfigRegistryTest.java
Show resolved
Hide resolved
...rc/test/java/com/ctrip/framework/apollo/spring/config/CachedCompositePropertySourceTest.java
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/AbstractConfigTest.java
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultConfigTest.java
Show resolved
Hide resolved
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/JavaConfigAnnotationTest.java
Show resolved
Hide resolved
...ient/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
Show resolved
Hide resolved
...ient/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java
Outdated
Show resolved
Hide resolved
...o-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java
Outdated
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java
Show resolved
Hide resolved
...lo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
Outdated
Show resolved
Hide resolved
...lo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
Outdated
Show resolved
Hide resolved
...lo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
Outdated
Show resolved
Hide resolved
protected static void doTearDown(){ | ||
MockInjector.reset(); | ||
CONFIG_REGISTRY.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are additional comments as mentioned above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (7)
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (3)
58-59
: LGTM: Test setup improved with app ID and property sources mocking.The changes in the
setUp
method enhance the test environment by:
- Introducing a consistent
someAppId
for testing.- Setting the
APP_ID
system property to mimic a real scenario.- Mocking
environment.getPropertySources()
for proper interaction testing.These changes improve the test's ability to simulate real-world conditions.
Consider moving the
someAppId
declaration to be a class-level constant, as it's used in multiple test methods:private static final String SOME_APP_ID = "someAppId";This would improve consistency and make it easier to update the app ID across all tests if needed.
Also applies to: 63-64, 69-69
86-86
: LGTM: Test updated to include app ID in configurations and assertions.The
testInitializePropertySources
method has been correctly updated to:
- Use
someAppId
inmockConfig
calls, reflecting the new multi-app ID support.- Update assertions to check for the correct property source names, now including the app ID.
These changes ensure that the test accurately verifies the new behavior of including app IDs in namespace configurations.
For consistency with the suggested class-level constant, replace the local
someAppId
declaration with the constant:- String someAppId = "someAppId"; + // Use the class-level constant SOME_APP_ID insteadThis would eliminate redundancy and ensure consistent use of the app ID across all test methods.
Also applies to: 91-92, 110-110, 112-112
118-118
: LGTM: Test updated to include app ID in configuration mocking.The
testApplicationEvent
method has been correctly updated to usesomeAppId
in themockConfig
call, maintaining consistency with the multi-app ID support changes.For consistency with the previous suggestion and to reduce redundancy, replace the local
someAppId
declaration with the proposed class-level constant:- String someAppId = "someAppId"; + // Use the class-level constant SOME_APP_ID insteadThis change would ensure consistent use of the app ID across all test methods and improve maintainability.
Also applies to: 121-121
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (3)
31-33
: Remove unused import.The import
com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor
on line 38 is not used in the visible changes. Consider removing it to keep the imports clean and avoid potential confusion.Also applies to: 38-38
586-593
: LGTM: New method to support multi-app ID feature.The addition of
getAccessKeySecret(String appId)
in the MockConfigUtil class correctly supports the new multi-app ID feature. It allows for different access key secrets for different app IDs, which is aligned with the expected behavior.Consider adding a default return value (e.g., an empty string) instead of
null
for unknown app IDs to prevent potential null pointer exceptions.@Override public String getAccessKeySecret(String appId){ if(appId.equals(someAppId)){ return someSecret; } - return null; + return ""; }
Line range hint
1-593
: Consider adding tests for edge cases.The current tests cover the basic functionality of the multi-app ID feature well. However, to improve robustness, consider adding test cases for edge cases such as:
- Empty app ID
- Null app ID
- App ID with special characters
- Very long app ID
These additional tests would help ensure the code handles various scenarios correctly and improve overall test coverage.
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (1)
82-84
: Add JavaDoc comments for the new public methodTo maintain consistency and improve code readability, please add JavaDoc comments for the newly added
getConfig(String appId, String namespace)
method, similar to the existinggetConfig
methods.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (9)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (2 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (6 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (10 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (11 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (7 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (7 hunks)
🧰 Additional context used
📓 Learnings (2)
apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (2)
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java:64-64 Timestamp: 2024-10-01T03:05:09.661Z Learning: In the `PropertySourcesProcessor` class, the `APP_NAMESPACE_NAMES` map and its inner `Multimap` instances do not need to be thread-safe because concurrent access is not expected.
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java:64-64 Timestamp: 2024-10-08T15:31:24.844Z Learning: In the `PropertySourcesProcessor` class, the `APP_NAMESPACE_NAMES` map and its inner `Multimap` instances do not need to be thread-safe because concurrent access is not expected.
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (1)
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java:64-64 Timestamp: 2024-10-01T03:05:09.661Z Learning: In the `PropertySourcesProcessor` class, the `APP_NAMESPACE_NAMES` map and its inner `Multimap` instances do not need to be thread-safe because concurrent access is not expected.
🔇 Additional comments (40)
apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessorTest.java (3)
19-25
: LGTM: Import statements updated appropriately.The new static imports for JUnit Assert and Mockito methods, as well as the additional imports for Java util and Spring core classes, are appropriate for the changes made in this test class. These imports improve code readability and indicate the use of new functionality in the test cases.
Also applies to: 37-37, 44-48
166-166
: LGTM: Minor adjustment in assertion order.The change in the assertion order for the property source name is a minor adjustment that doesn't affect the test's functionality. It likely improves readability or aligns with a preferred coding style.
Line range hint
1-167
: Summary: PropertySourcesProcessorTest.java successfully updated for multi-app ID supportThe changes in this file effectively update the test cases to support and verify the new multi-app ID feature. Key points:
- Consistent use of
someAppId
across test methods.- Updated mocking and assertions to include app ID in configurations and property source names.
- Maintained existing test coverage while adapting to the new feature.
The suggested improvements (using a class-level constant for
someAppId
) would further enhance consistency and maintainability. Overall, the changes are well-implemented and provide good coverage for the new functionality.apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java (4)
87-89
: LGTM: Good initialization of test variables.The addition of
someAppId
andsomeCluster
in thesetUp
method is a good practice. It centralizes the initialization of these variables, which are likely used across multiple test methods to support the new multi-app ID feature.
142-142
: LGTM: Updated method call to support multi-app ID feature.The
submit
method call has been correctly updated to includesomeAppId
as the first parameter, aligning with the new multi-app ID feature implementation.
193-193
: LGTM: Consistent updates to support multi-app ID feature.All
submit
method calls have been consistently updated to includesomeAppId
as the first parameter. This change properly implements the new multi-app ID feature across all relevant test methods, ensuring comprehensive test coverage for the new functionality.Also applies to: 255-255, 326-326, 329-329, 397-398, 458-458
Line range hint
1-593
: Overall, excellent implementation of multi-app ID feature tests.The changes in this file consistently and effectively implement tests for the new multi-app ID feature. Key points:
- All relevant test methods have been updated to include the app ID parameter.
- The MockConfigUtil class has been extended to support app ID-specific access key secrets.
- The code maintains good structure and follows testing best practices.
The implementation thoroughly covers the new functionality while preserving existing test coverage. Great job on maintaining code quality and test comprehensiveness throughout these changes.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java (1)
31-31
: Thread-safety ensured form_factories
The
m_factories
variable is now wrapped withTables.synchronizedTable()
, which ensures thread safety in a concurrent environment.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (1)
97-100
: Inconsistency in usingnamespaceFileName
ingetFactory
andcreateConfigFile
As previously noted, passing
namespaceFileName
(which includes the file extension) instead ofnamespace
togetFactory
andcreateConfigFile
may cause inconsistencies if the factory expects the logicalnamespace
without the file extension.apollo-client/src/test/java/com/ctrip/framework/apollo/ConfigServiceTest.java (15)
64-64
: Update usage ofConfigService.setConfig()
to match new constructor parametersThe
MockConfig
constructor now requires anappId
parameter. The invocation ofConfigService.setConfig()
correctly reflects this change by passingsomeAppId
andsomeNamespace
.
68-68
: Ensure assertions reflect the new key format includingappId
The assertion now includes
someAppId
in the expected property key, which aligns with the updatedgetProperty
method inMockConfig
that returns keys formatted withappId
andnamespace
.
79-79
: Update test to accommodate newappId
inclusion in property keysIn the
testHackConfigFactory
test method, the assertion has been updated to includesomeAppId
in the expected property key. This change is necessary due to the updatedMockConfig
behavior that now includesappId
in property keys.
91-91
: Modify test expectations to includeappId
inMockConfig
property keysThe assertion in
testMockConfigFactory
correctly updates the expected value by includingsomeAppId
, matching the new key format returned byMockConfig
.
109-110
: Introducem_appId
field toMockConfig
The addition of
private final String m_appId;
inMockConfig
is necessary to store theappId
passed to the constructor, enabling the class to use it in property key generation.
112-113
: UpdateMockConfig
constructor to acceptappId
The constructor now accepts
String appId
as a parameter, allowing instances ofMockConfig
to be associated with a specific application ID. This change supports the enhanced configuration management for multiple app IDs.
123-123
: ModifygetProperty
method to includeappId
in the returned keyThe
getProperty
method now returns a key formatted withm_appId
andm_namespace
, enhancing the uniqueness of property keys across different applications and namespaces.
139-140
: Addm_appId
field toMockConfigFile
Introducing
private String m_appId;
inMockConfigFile
allows the class to store the application ID, which is essential for application-specific configuration files.
148-153
: Add new constructor toMockConfigFile
acceptingappId
The new constructor enables
MockConfigFile
to be instantiated with anappId
,namespace
, andconfigFileFormat
. This supports application-specific configuration file handling.
165-168
: ImplementgetAppId()
method inMockConfigFile
The
getAppId()
method correctly returnsm_appId
, ensuring that the application ID can be retrieved fromMockConfigFile
instances. This change addresses the previous issue wheregetAppId()
returnednull
.
199-200
: Delegate to newcreate(String appId, String namespace)
methodIn
MockConfigFactory
, the existingcreate(String namespace)
method now delegates to the newcreate(String appId, String namespace)
method, ensuring consistency in object creation with the inclusion ofappId
.
202-204
: Addcreate(String appId, String namespace)
method toMockConfigFactory
This new method allows
MockConfigFactory
to createConfig
instances with a specificappId
andnamespace
, supporting the enhanced multi-application configuration management.
209-210
: Delegate to newcreateConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
methodThe existing
createConfigFile(String namespace, ConfigFileFormat configFileFormat)
method now calls the new method that includesappId
, ensuring thatConfigFile
instances are created with the correct application context.
212-214
: AddcreateConfigFile(String appId, String namespace, ConfigFileFormat configFileFormat)
methodThis method in
MockConfigFactory
createsMockConfigFile
instances with the specifiedappId
,namespace
, andconfigFileFormat
, aligning with the application's requirement to support multiple app IDs.
199-214
: Verify consistency in factory method overridesEnsure that all overridden methods in
MockConfigFactory
correctly handle the addition ofappId
. The new methods enhance the factory's ability to produce configuration objects that are aware of application IDs.Run the following script to confirm that all factory methods correctly handle
appId
:apollo-client/src/main/java/com/ctrip/framework/apollo/spring/config/PropertySourcesProcessor.java (5)
64-64
: LGTM: Introduction ofAPP_NAMESPACE_NAMES
to support multiple app IDsThe change from
NAMESPACE_NAMES
toAPP_NAMESPACE_NAMES
appropriately updates the data structure to handle multiple app IDs, aligning with the PR objectives of enhancing configuration capabilities.
74-75
: LGTM: OverloadedaddNamespaces
method delegates correctlyThe method
addNamespaces(Collection<String> namespaces, int order)
correctly delegates to the new overloaded method by obtaining theappId
usingConfigUtil
and passes it along with the namespaces and order.
77-83
: LGTM: Proper handling of namespaces withinaddNamespaces
The
addNamespaces(String appId, Collection<String> namespaces, int order)
method correctly updatesAPP_NAMESPACE_NAMES
by associating namespaces with the specifiedappId
andorder
. The logic ensures namespaces are organized per application ID.
106-122
: LGTM:initializePropertySources
method updated for multiple app IDsThe iteration over
APP_NAMESPACE_NAMES
ininitializePropertySources
properly processes eachappId
and its associated namespaces. The construction of property sources now accommodates multiple app IDs, effectively supporting the PR's goal.
178-180
: LGTM: Reset functionality updated appropriatelyThe
reset()
method correctly clearsAPP_NAMESPACE_NAMES
andAUTO_UPDATE_INITIALIZED_BEAN_FACTORIES
, ensuring the class resets its state as expected.apollo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java (2)
99-99
: Correct usage ofnamespaceName
inSimpleConfig
initializationGood job updating the
SimpleConfig
constructor to usenamespaceName
. This ensures that configurations are correctly associated with their respective namespaces.
200-200
: ClearedCONFIG_FILE_REGISTRY
indoTearDown
methodAdding
CONFIG_FILE_REGISTRY.clear();
ensures that residual states are removed after tests, preventing interference with subsequent tests.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (9)
42-49
: Appropriate imports for new data structuresThe added imports for
HashBasedTable
,Table
, andTables
are necessary and correct for the implementation of the new data structures used in the class.
82-84
: Proper initialization of thread-safe collectionsThe utilization of
ConcurrentHashMap
form_longPollStarted
, a concurrent map form_longPollNamespaces
, and a synchronizedTable
form_notifications
ensures thread safety across concurrent operations.
100-104
: Consistent use of cached thread poolSwitching to
Executors.newCachedThreadPool
form_longPollingService
aligns with best practices for managing dynamic workloads and enhances performance in a multi-application environment.
114-123
: Thread-safe repository submission withcomputeIfAbsent
Implementing
computeIfAbsent
form_longPollNamespaces
effectively eliminates race conditions when multiple threads submit repositories for the sameappId
, ensuring atomic initialization ofrepositoryMultimap
.
127-129
: Atomic check-and-set for starting long pollingUsing
putIfAbsent
onm_longPollStarted
provides an atomic operation to prevent multiple threads from starting redundant long polling for the sameappId
.
152-152
: Proper cleanup on exceptionRemoving the
appId
fromm_longPollStarted
in the catch block ensures that the system can retry starting long polling if an exception occurs during initialization.
238-241
: Null check prevents potentialNullPointerException
Adding a null check for
namespaceRepositories
in thenotify
method safeguards against a possibleNullPointerException
if no repositories are registered for a givenappId
.
262-275
: Accurate update of notifications perappId
The
updateNotifications
method correctly updates notification IDs for each namespace under the specifiedappId
, ensuring that the notification system functions accurately in a multi-application context.
301-306
: Safely assembling namespaces with null checksIncluding a null check in the
assembleNamespaces
method prevents errors when no namespaces are registered for anappId
, enhancing the robustness of the method.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Show resolved
Hide resolved
...lo-client/src/test/java/com/ctrip/framework/apollo/spring/AbstractSpringIntegrationTest.java
Show resolved
Hide resolved
# Conflicts: # apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java # apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java # apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java # apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java # apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
🧹 Outside diff range and nitpick comments (12)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (1)
67-70
: LGTM! Consider adding null check and updating documentation.The changes to the
fireRepositoryChange
method align well with the PR objectives of supporting multiple app IDs. The addition of theappId
parameter is consistent with similar updates across the codebase, as evidenced by the retrieved learnings.To further improve the implementation:
- Consider adding a null check for the
appId
parameter to enhance robustness:if (appId == null) { logger.warn("Received null appId in fireRepositoryChange. Using default or throwing an exception might be appropriate."); // Decide whether to use a default value or throw an exception }
- Update the method's documentation to reflect the new
appId
parameter:/** * Notifies all registered listeners of a repository change. * * @param appId The ID of the application for which the change occurred * @param namespace The namespace of the changed properties * @param newProperties The new set of properties */ protected void fireRepositoryChange(String appId, String namespace, Properties newProperties) { // ... existing implementation ... }apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java (1)
40-41
: LGTM! Consider adding a brief comment for clarity.The constructor change aligns with the PR objectives to support multiple app IDs. The implementation looks correct and consistent with changes in other classes.
Consider adding a brief comment explaining the purpose of the
appId
parameter for better clarity:public YamlConfigFile(String appId, String namespace, ConfigRepository configRepository) { + // appId is used to support multiple application configurations super(appId, namespace, configRepository); tryTransformToProperties(); }
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (2)
59-61
: Well-implemented getConfig method changesThe changes to the
getConfig
method effectively introduce multi-application support while maintaining backward compatibility. The new overloaded method correctly uses theTable
data structure and updates the locking mechanism appropriately.Consider optimizing the lock key generation:
-Object lock = m_configLocks.computeIfAbsent(String.format("%s.%s", appId, namespace), key -> new Object()); +Object lock = m_configLocks.computeIfAbsent(appId + "." + namespace, key -> new Object());This change reduces the overhead of
String.format
in a potentially high-frequency operation.Also applies to: 63-76
Line range hint
37-37
: Well-implemented multi-application support with minor suggestionThe overall changes to
DefaultConfigManager
effectively implement multi-application support while maintaining backward compatibility and thread-safety. The class structure remains consistent and well-organized.As a minor suggestion:
Consider updating the class-level JavaDoc to reflect the new multi-application support feature. This will help future developers understand the enhanced capabilities of this class.
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (1)
226-226
: LGTM! Consider adding a comment for clarity.The change correctly updates the test to use the new
getDefaultLocalCacheDir(appId)
method signature. This aligns with the new functionality of supporting multiple app IDs.Consider adding a brief comment explaining the purpose of including
someAppId
in the expected result, to enhance test readability:// Verify that the cache directory includes both the system property value and the app ID assertEquals(someCacheDir + File.separator + someAppId, configUtil.getDefaultLocalCacheDir(someAppId));apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (2)
321-330
: Consider adding a null check for theappId
parameter.The method implementation looks good and follows the existing coding standards. However, to improve robustness, consider adding a null check for the
appId
parameter at the beginning of the method.Here's a suggested implementation:
public String getDefaultLocalCacheDir(String appId) { + if (Strings.isNullOrEmpty(appId)) { + throw new IllegalArgumentException("appId must not be null or empty"); + } String cacheRoot = getCustomizedCacheRoot(); if (!Strings.isNullOrEmpty(cacheRoot)) { return cacheRoot + File.separator + appId; } cacheRoot = isOSWindows() ? "C:\\opt\\data\\%s" : "/opt/data/%s"; return String.format(cacheRoot, appId); }
602-604
: Approve implementation with a suggestion for null check.The implementation looks good and correctly delegates the call to
Foundation.app().getAccessKeySecret(appId)
. However, consider adding a null check for theappId
parameter to improve robustness.Here's a suggested implementation:
public String getAccessKeySecret(String appId){ + if (Strings.isNullOrEmpty(appId)) { + throw new IllegalArgumentException("appId must not be null or empty"); + } return Foundation.app().getAccessKeySecret(appId); }apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (1)
66-70
: Consider adding unit tests for the new constructorAdding unit tests for scenarios with and without a provided
appId
will enhance test coverage and ensure the new logic functions as intended.Would you like assistance in creating these unit tests or opening a GitHub issue to track this task?
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (1)
96-98
: Add missing JavaDoc for the new public methodThe new public method
getConfig(String appId, String namespace)
lacks a JavaDoc comment. Adding documentation will improve code readability and help other developers understand its purpose and usage.Apply this change to add JavaDoc for the method:
+ /** + * Get the config instance for the specified appId and namespace. + * + * @param appId the application ID + * @param namespace the namespace of the config + * @return config instance + */ public static Config getConfig(String appId, String namespace) { return s_instance.getManager().getConfig(appId, namespace); }apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (1)
Line range hint
105-127
: Method parametersappId
andnamespace
are not used withinonRepositoryChange
In the method
onRepositoryChange(String appId, String namespace, Properties newProperties)
, the parametersappId
andnamespace
are not utilized inside the method body. Instead, the class fieldsm_appId
andm_namespace
are used. This could lead to unexpected behavior if the passed parameters differ from the class fields.Consider using the method parameters within the method to ensure consistency and correct handling of the provided arguments.
Apply this diff to fix the issue:
public synchronized void onRepositoryChange(String appId, String namespace, Properties newProperties) { if (newProperties.equals(m_configProperties.get())) { return; } Properties newConfigProperties = propertiesFactory.getPropertiesInstance(); newConfigProperties.putAll(newProperties); String oldValue = getContent(); update(newProperties); m_sourceType = m_configRepository.getSourceType(); String newValue = getContent(); PropertyChangeType changeType = PropertyChangeType.MODIFIED; if (oldValue == null) { changeType = PropertyChangeType.ADDED; } else if (newValue == null) { changeType = PropertyChangeType.DELETED; } - this.fireConfigChange(new ConfigFileChangeEvent(m_appId, m_namespace, oldValue, newValue, changeType)); + this.fireConfigChange(new ConfigFileChangeEvent(appId, namespace, oldValue, newValue, changeType)); - Tracer.logEvent(APOLLO_CLIENT_CONFIGCHANGES, m_namespace); + Tracer.logEvent(APOLLO_CLIENT_CONFIGCHANGES, namespace); }apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (2)
205-208
: Null Check forappId
ParameterIn the method
loadFromLocalCacheFile
, consider adding a null check for theappId
parameter to prevent potentialNullPointerException
.Apply this diff to add a null check:
private Properties loadFromLocalCacheFile(File baseDir, String appId, String namespace) throws IOException { + Preconditions.checkNotNull(appId, "appId cannot be null"); Preconditions.checkNotNull(baseDir, "Basedir cannot be null");
240-244
: Consistent Null Checks for ParametersSimilarly, in
persistLocalCacheFile
, ensure all parameters are validated to prevent unintended runtime exceptions.Apply this diff to add null checks:
void persistLocalCacheFile(File baseDir, String appId, String namespace) { if (baseDir == null) { return; } + Preconditions.checkNotNull(appId, "appId cannot be null"); + Preconditions.checkNotNull(namespace, "namespace cannot be null"); File file = assembleLocalCacheFile(baseDir, appId, namespace);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (13)
- apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (4 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (7 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (3 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (8 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (12 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (5 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java (1 hunks)
- apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java (2 hunks)
- apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (2 hunks)
🧰 Additional context used
📓 Learnings (3)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (1)
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/CachedCompositePropertySourceTest.java:85-85 Timestamp: 2024-10-19T12:52:36.706Z Learning: In the Java class `ConfigChangeEvent` (`apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java`), the constructor has been updated to accept three parameters: `String appId`, `String namespace`, and `Map<String, ConfigChange> changes`.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java (2)
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java:32-38 Timestamp: 2024-10-19T12:48:00.553Z Learning: In the Apollo Java client, the class `PureApolloConfig` extends `DefaultConfig`, which implements the `onRepositoryChange(String appId, String namespace, Properties newProperties)` method from the `RepositoryChangeListener` interface. Therefore, `PureApolloConfig` doesn't need its own implementation of this method.
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/CachedCompositePropertySourceTest.java:85-85 Timestamp: 2024-10-19T12:52:36.706Z Learning: In the Java class `ConfigChangeEvent` (`apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java`), the constructor has been updated to accept three parameters: `String appId`, `String namespace`, and `Map<String, ConfigChange> changes`.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (2)
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/test/java/com/ctrip/framework/apollo/spring/config/CachedCompositePropertySourceTest.java:85-85 Timestamp: 2024-10-19T12:52:36.706Z Learning: In the Java class `ConfigChangeEvent` (`apollo-client/src/main/java/com/ctrip/framework/apollo/model/ConfigChangeEvent.java`), the constructor has been updated to accept three parameters: `String appId`, `String namespace`, and `Map<String, ConfigChange> changes`.
Learnt from: nobodyiam PR: apolloconfig/apollo-java#70 File: apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RepositoryChangeListener.java:32-38 Timestamp: 2024-10-19T12:48:00.553Z Learning: In the Apollo Java client, the class `PureApolloConfig` extends `DefaultConfig`, which implements the `onRepositoryChange(String appId, String namespace, Properties newProperties)` method from the `RepositoryChangeListener` interface. Therefore, `PureApolloConfig` doesn't need its own implementation of this method.
🔇 Additional comments (44)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java (4)
28-29
: Improved data structure for multi-application supportThe changes to import statements and data structures are well-implemented:
- The use of
Table
instead ofMap
allows for efficient storage and retrieval of configurations based on bothappId
andnamespace
.Tables.synchronizedTable
ensures thread-safety for the new data structures.These changes effectively support the multi-application configuration management feature.
Also applies to: 32-33, 44-45, 48-49
42-43
: Appropriate addition of ConfigUtilThe addition of
ConfigUtil
as a member variable and its initialization in the constructor usingApolloInjector
is appropriate. This change supports the retrieval of the application ID in various methods, which is crucial for the multi-application support feature.Also applies to: 55-55
73-75
: Appropriate updates to ConfigFactory usageThe changes to
ConfigFactory
usage, including the addition of theappId
parameter togetFactory
,create
, andcreateConfigFile
methods, are consistent with the multi-application support feature. These updates ensure that the correct factory is used for eachappId
andnamespace
combination.Also applies to: 104-106
76-76
: Effective updates to configuration storageThe changes to configuration storage, including the use of
Table
data structures and the addition ofappId
in put operations, are well-implemented. These updates ensure that configurations are correctly stored and retrieved based on bothappId
andnamespace
, which is crucial for the multi-application support feature.Also applies to: 107-107
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (1)
239-239
: LGTM! Consider addressing the existing comment about hardcoded paths.The changes correctly update the test to use the new
getDefaultLocalCacheDir(appId)
method signature for both Windows and non-Windows systems. This aligns with the new functionality of supporting multiple app IDs.The existing comment about hardcoded paths in the tests is still relevant. Consider addressing this issue to make the tests more robust and environment-independent.
Also applies to: 243-243
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java (6)
43-43
: Addition ofm_appId
enhances multi-application supportThe introduction of the
m_appId
field effectively supports configurations for multiple application IDs withinSimpleConfig
.
56-58
: Original constructor is preserved and delegates appropriatelyBy retaining the original constructor and delegating to the new one, backward compatibility is maintained.
66-70
: Proper handling ofappId
in the new constructorThe overloaded constructor correctly initializes
m_appId
, ensuring that whenappId
isnull
, it defaults to the configured application ID.
115-116
: Consistent use ofm_appId
inonRepositoryChange
Using
m_appId
when delegating to the overloadedonRepositoryChange
ensures consistency with the instance's application ID.
Line range hint
118-138
: Appropriate propagation ofappId
in configuration change handlingThe updated
onRepositoryChange
method and subsequent calls correctly utilizeappId
, ensuring that configuration changes are accurately associated with the correct application context.
138-138
: Alignment with previous reviewer feedback onfireConfigChange
Using the passed
appId
infireConfigChange
reflects adherence to previous review suggestions and promotes consistency.apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java (2)
130-134
:⚠️ Potential issueRe-evaluate the appId matching logic for multiple appId support
The current implementation in
create(String appId, String namespace)
only returns theconfig
if the providedappId
matches the defaultappId
. This behavior restricts the support for multiple appIds, as it doesn't allow configurations for different appIds to be retrieved.Please verify if this implementation aligns with the intention of supporting multiple appIds. If the goal is to fetch configurations for various appIds, consider adjusting the logic to handle different appIds appropriately.
121-122
: 🛠️ Refactor suggestionLimit the scope of
m_configUtil
The variable
m_configUtil
is declared at the class level within the anonymousConfigFactory
, but it's only used in thecreate(String appId, String namespace)
method. To improve code readability and maintainability, consider moving its declaration inside the method to limit its scope.Apply this change to adjust the scope of
m_configUtil
:- private final ConfigUtil m_configUtil = ApolloInjector.getInstance(ConfigUtil.class); @Override public Config create(String appId, String namespace) { + ConfigUtil m_configUtil = ApolloInjector.getInstance(ConfigUtil.class); if(!StringUtils.equals(appId, m_configUtil.getAppId())){ throw new IllegalArgumentException("Provided appId '" + appId + "' does not match the default appId '" + m_configUtil.getAppId() + "'"); } return config; }Likely invalid or redundant comment.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java (2)
50-50
: LGTM!The addition of
m_appId
as a protected field enhances the ability to manage configurations specific to an application.
87-91
: LGTM!Providing the
getAppId()
method offers necessary access to the application ID for external classes.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java (4)
301-301
: Ensure Cluster Information Is Correctly RetrievedIn the
assembleLocalCacheFile
method, you are joiningappId
,m_configUtil.getCluster()
, andnamespace
. Verify thatm_configUtil.getCluster()
returns the correct cluster information, especially in multi-app scenarios.Run the following script to check usages of
getCluster
and ensure consistency:#!/bin/bash # Description: Verify that `getCluster()` is used appropriately. # Test: Search for `getCluster()` usages. Expect: Consistent use across the codebase. rg 'getCluster\(\)'
298-301
: Validate File Naming Convention for Cache FilesThe cache file name now includes the
appId
. Ensure that this naming convention aligns with other parts of the system that read from or write to these cache files to prevent any file access discrepancies.Run the following script to find usages of
assembleLocalCacheFile
and verify consistency:#!/bin/bash # Description: Find all usages of `assembleLocalCacheFile` to ensure consistent file naming. # Test: Search for calls to `assembleLocalCacheFile`. Expect: All calls include `appId`. rg 'assembleLocalCacheFile\([^,]+,\s*appId,\s*[^)]+\)'
137-138
:⚠️ Potential issueIncorrect Use of
@Override
AnnotationThe method
public void onRepositoryChange(String appId, String namespace, Properties newProperties)
is annotated with@Override
, but it does not override any method from a superclass or interface. This will lead to a compilation error.Remove the
@Override
annotation to fix the compilation error:- @Override public void onRepositoryChange(String appId, String namespace, Properties newProperties) {
Likely invalid or redundant comment.
71-72
: Ensure Upstream Repository HandlesappId
AppropriatelyWhen setting the upstream repository with the
appId
, ensure that the upstream repository is also aware of theappId
parameter to prevent any inconsistency in configuration fetching.Run the following script to check if
appId
is properly used in upstream repositories:✅ Verification successful
Upstream Repositories Handle
appId
AppropriatelyVerified that all upstream repositories instantiate with the
appId
parameter correctly, ensuring consistent configuration fetching.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that upstream repositories are instantiated with the correct `appId`. # Test: Search for instantiations of upstream repositories with `appId`. # Expect: All upstream repositories should accept `appId` if required. rg -A 5 'new .*Repository\(.*appId.*\)'Length of output: 492
Script:
#!/bin/bash # Description: Verify that upstream repositories are instantiated with the correct `appId`. # Corrected Test: Search for instantiations of upstream repositories with `appId`. # Expect: All upstream repositories should accept `appId` if required. rg -A 5 'new .*Repository\(.*appId.*\)'Length of output: 1628
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java (3)
53-53
: Ensurem_appId
is properly initializedThe new member variable
m_appId
is crucial for multi-app support. Please verify that it is correctly initialized in all constructors to prevent anyNullPointerException
and ensure consistent behavior across the application.
69-70
: Maintain backward compatibility with the default constructorUsing
this(null, namespace, configRepository);
in the default constructor ensures backward compatibility. Passingnull
forappId
should correctly default to the configuredappId
. This approach allows existing code to function without modification.
262-262
: VerifyfireConfigChange
handles theappId
correctlyEnsure that the
fireConfigChange
method and its listeners are updated to handle the additionalappId
parameter properly. This verification is essential to prevent any unexpected behavior during configuration changes.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java (5)
77-77
: Addition ofm_appId
field is appropriateThe new field
private final String m_appId;
will store theappId
provided during instantiation, which is necessary for supporting multiple app IDs.
165-165
: Updated method call tofireRepositoryChange
The call to
this.fireRepositoryChange
now includesm_appId
as an argument, aligning with the updated method signature to support multiple app IDs.
196-199
: Consistent usage ofm_appId
for configurationReplaced
String appId = m_configUtil.getAppId();
withString appId = this.m_appId;
to ensure that theappId
provided during instantiation is consistently used throughout the class. Additionally, retrieving the secret using the correctappId
ensures that the appropriate access key is used.
343-343
: Long polling submission updated withm_appId
The call to
remoteConfigLongPollService.submit
now passesm_appId
as the first parameter. Verify that theRemoteConfigLongPollService
class and itssubmit
method have been updated to accept theappId
parameter.Run the following script to confirm that
RemoteConfigLongPollService.submit
has been updated to acceptappId
:#!/bin/bash # Description: Check the method signature of RemoteConfigLongPollService.submit # Search for the submit method definition in RemoteConfigLongPollService. rg 'public\s+void\s+submit\s*\(' -A 5
95-99
: Constructor updated to acceptappId
The constructor now accepts
String appId
and assigns it tom_appId
. The JavaDoc comment has been updated accordingly. Ensure that all instances whereRemoteConfigRepository
is instantiated are updated to pass the correctappId
.Run the following script to verify that all instantiations of
RemoteConfigRepository
include theappId
parameter:✅ Verification successful
All instantiations of
RemoteConfigRepository
include theappId
parameter.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all instantiations of RemoteConfigRepository and check for the appId parameter. # Search for 'new RemoteConfigRepository' and display the lines where it occurs. rg 'new\s+RemoteConfigRepository\s*\(' -A 2Length of output: 133
Script:
#!/bin/bash # Description: Find all instantiations of RemoteConfigRepository and check for the appId parameter. # Search for 'new RemoteConfigRepository' and display the lines where it occurs along with their parameters. rg 'new\s+RemoteConfigRepository\s*\(([^)]*)\)'Length of output: 1815
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollService.java (14)
43-43
: Appropriate Imports for New Data StructuresThe imports for
HashBasedTable
,Table
, andTables
are necessary for implementing the new data structures used in the class. Good job on explicitly adding them.Also applies to: 49-50
60-60
: Addition ofConcurrentHashMap
ImportImporting
ConcurrentHashMap
is essential for the thread-safe operations introduced in the code. This import is appropriate and aligns with the concurrent data structures used.
84-86
: Use of Thread-Safe Data Structures for Multi-App SupportThe introduction of
ConcurrentHashMap
form_longPollStarted
,Map<String, Multimap<String, RemoteConfigRepository>>
form_longPollNamespaces
, andTable<String, String, Long>
form_notifications
enhances thread safety and properly supports multi-application configurations.
102-102
: Initialization of Thread Pool and Data StructuresUsing
Executors.newCachedThreadPool
improves resource utilization for the long polling service. Initializingm_longPollStarted
,m_longPollNamespaces
, andm_notifications
appropriately sets up the necessary data structures for multi-app support.Also applies to: 104-106
116-125
: Thread-Safe Submission insubmit
MethodThe use of
computeIfAbsent
forrepositoryMultimap
inm_longPollNamespaces
ensures thread-safe initialization, preventing race conditions when multiple threads submit different namespaces with the sameappId
. The logic for starting long polling perappId
is correctly implemented.
128-129
: Concurrency Handling instartLongPolling
MethodThe check using
putIfAbsent
onm_longPollStarted
effectively prevents multiple threads from starting the long polling for the sameappId
concurrently. This is a proper way to handle concurrency.
154-154
: Cleaning Upm_longPollStarted
on FailureRemoving
sysAppId
fromm_longPollStarted
in the catch block ensures that if starting the long polling fails, it can be retried in the future. Good practice for handling exceptions.
185-185
: Passing Notifications Per Application in URL AssemblyUsing
m_notifications.row(appId)
when assembling the long poll refresh URL correctly limits the notifications to the specifiedappId
, aligning with the multi-app support.
203-203
: Updating Methods to IncludeappId
ParameterModifying the
updateNotifications
andnotify
methods to includeappId
ensures that notifications are correctly processed per application. This change is consistent with the multi-application architecture.Also applies to: 206-206
223-223
: Enhanced Logging with Application ContextIncluding
appId
in logging statements and tracing events provides better context for debugging and monitoring, especially in a multi-application environment.Also applies to: 227-227
239-246
: Null Check innotify
Method to PreventNullPointerException
Adding a null check for
namespaceRepositories
ensures that the method handles cases where theappId
is not present, preventing potentialNullPointerException
.
251-251
: Collecting Repositories to NotifyGathering the
RemoteConfigRepository
instances using theappId
andnamespaceName
correctly identifies which repositories need to be notified. Including the.properties
suffix accounts for different namespace formats.Also applies to: 255-256
267-267
: Proper Notification Updates inupdateNotifications
Updating notifications with the
appId
key ensures that notification IDs are maintained per application. Checks for the existence of the namespace before updating prevent unintended entries.Also applies to: 273-274, 279-280
306-311
: Null Handling inassembleNamespaces
MethodThe null check for
namespaceRepositories
inassembleNamespaces
prevents errors when no namespaces exist for anappId
, ensuring the method returns an empty string in such cases.apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java (3)
Line range hint
457-469
: Inclusion ofappId
enhances multi-application supportThe
fireConfigChange
method now includes theappId
parameter, which improves configuration change tracking across different applications. This update aligns with the goal of supporting multipleappId
s as specified in the PR objectives.
Line range hint
570-608
:calcPropertyChanges
method updated withappId
parameterAdding
appId
to thecalcPropertyChanges
method ensures that configuration changes are accurately associated with the correct application, enhancing the configurability and traceability of changes.
Line range hint
590-608
:ConfigChange
instances now includeappId
for better contextThe creation of
ConfigChange
objects now includes theappId
, which provides additional context and aligns with the updates to support multiple application IDs. This change is consistent with modifications in other parts of the codebase.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/YamlConfigFile.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfigManager.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/SimpleConfig.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
Show resolved
Hide resolved
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
Show resolved
Hide resolved
Jason, my unit tests pass perfectly when I run them locally, but fail when I run them on GitHub. |
@@ -28,11 +28,14 @@ | |||
import static org.mockito.Mockito.verify; | |||
import static org.mockito.Mockito.when; | |||
|
|||
import com.ctrip.framework.apollo.build.ApolloInjector; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these imports are not used.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactoryManager.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the unit test in my local environment and get the same errors.
[ERROR] Failures:
[ERROR] ConfigIntegrationTest.testGetConfigWithLocalFileAndRemoteConfigError:179 expected: <someValue> but was: <anotherValue>
[ERROR] ConfigIntegrationTest.testGetConfigWithNoLocalFileAndRemoteConfigError:164 expected: <defaultValue0.4766152787709471> but was: <someValue>
[ERROR] ConfigIntegrationTest.testOrderGetConfigWithLocalFileAndRemoteConfigError:201 expected: <someValue1> but was: <null>
[ERROR] ConfigServiceTimeoutIntegrationTest.give9NamespaceConfigBackupWhenMeetTimeout:156 expected: <backupNs0.v1> but was: <null>
[ERROR] ConfigServiceTimeoutIntegrationTest.giveDefaultNamespaceConfigBackupWhenMeetTimeout:96 expected: <v1> but was: <null>
[ERROR] ConfigServiceTimeoutIntegrationTest.giveTimeoutThenRecover:198 expected: <v1> but was: <null>
[ERROR] ConfigServiceLocatorTest.giveNoUsableConfigServiceThenThrowExceptionQuickly:84 Expected com.ctrip.framework.apollo.exceptions.ApolloConfigException to be thrown, but nothing was thrown.
[INFO]
[ERROR] Tests run: 428, Failures: 7, Errors: 0, Skipped: 1
# Conflicts: # apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (6)
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (1)
241-245
: Consider parameterizing the test cases.While the test correctly verifies the appId inclusion for both Windows and Unix paths, we can make it more maintainable by:
- Using parameterized tests to avoid code duplication
- Moving the OS-specific base paths to constants or test configuration
- Adding test cases for different appId values
Example refactor:
@ParameterizedTest @MethodSource("provideOsTestCases") void testDefaultLocalCacheDir(boolean isWindows, String expectedBasePath, String appId) { ConfigUtil configUtil = spy(new ConfigUtil()); doReturn(appId).when(configUtil).getAppId(); doReturn(isWindows).when(configUtil).isOSWindows(); String expected = expectedBasePath + appId; assertEquals(expected, configUtil.getDefaultLocalCacheDir(appId)); } private static Stream<Arguments> provideOsTestCases() { return Stream.of( Arguments.of(true, "C:\\opt\\data\\", "app1"), Arguments.of(false, "/opt/data/", "app1"), Arguments.of(true, "C:\\opt\\data\\", "app2"), Arguments.of(false, "/opt/data/", "app2") ); }apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (5)
89-89
: Update log message to includeappId
for clarityThe debug log currently mentions only the repository type and namespace:
logger.debug("Created a configuration repository of type [{}] for namespace [{}]", configRepository.getClass().getName(), namespace);Consider including
appId
in the log message to provide more context, especially now that configurations are app-specific.Apply this diff to enhance the log message:
logger.debug("Created a configuration repository of type [{}] for namespace [{}]", - configRepository.getClass().getName(), namespace); + configRepository.getClass().getName(), namespace, appId);Update the log message format accordingly.
99-100
: NewcreateRepositoryConfig
method centralizesDefaultConfig
creationIntroducing
createRepositoryConfig(String appId, String namespace, ConfigRepository configRepository)
centralizes the creation ofDefaultConfig
instances, promoting code reuse and maintainability.
136-147
: Update JavaDoc comments to includeappId
parameterThe JavaDoc for
createLocalConfigRepository
mentions@param appId
but does not explain it. Please provide a description for theappId
parameter to improve code documentation.Apply this diff to update the JavaDoc:
/** * Creates a local repository for a given namespace * + * @param appId the application ID of the repository * @param namespace the namespace of the repository * @return the newly created repository for the given namespace */
163-164
: Potential issue withtrimNamespaceFormat
usingappId
The method
trimNamespaceFormat
now includesappId
:String actualNamespaceName = trimNamespaceFormat(appId, namespace, format);However, in the implementation:
String trimNamespaceFormat(String appId, String namespaceName, ConfigFileFormat format) { String extension = "." + format.getValue(); // ... }
appId
is not used insidetrimNamespaceFormat
. IfappId
is not required, consider removing it from the method signature to avoid confusion.Apply this diff to remove the unused
appId
parameter:-String trimNamespaceFormat(String appId, String namespaceName, ConfigFileFormat format) { +String trimNamespaceFormat(String namespaceName, ConfigFileFormat format) {And update the method calls accordingly.
183-186
: Remove unusedappId
parameter fromtrimNamespaceFormat
As
appId
is not utilized within the method, retaining it may lead to confusion or future maintenance issues.Confirm if
appId
is intended to be used. If not, consider removing it as per the previous suggestion.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
(4 hunks)apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
(2 hunks)apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
🔇 Additional comments (12)
apollo-client/src/test/java/com/ctrip/framework/apollo/util/ConfigUtilTest.java (2)
228-228
: LGTM: Test correctly verifies cache directory path with appId.
The updated test properly verifies that the cache directory path includes the appId when a system property is set.
241-241
: Existing feedback about hardcoded paths still applies.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (10)
68-69
: Verify appId
initialization when calling overloaded create
method
The method m_configUtil.getAppId()
retrieves the appId
used in the overloaded create
method. Please ensure that appId
is properly initialized and cannot be null to prevent potential NullPointerException
issues.
To confirm that appId
is always initialized, consider adding a null check or default value in ConfigUtil.getAppId()
.
71-72
: Addition of overloaded create
method enhances configurability
The introduction of the overloaded create(String appId, String namespace)
method allows for configurations to be specified per appId
, aligning with the PR objective to support multiple appId
s.
82-83
: Ensure correct handling of properties-compatible formats
The condition checks if the format is properties-compatible but not exactly Properties
:
if (ConfigFileFormat.isPropertiesCompatible(format) &&
format != ConfigFileFormat.Properties) {
configRepository = createPropertiesCompatibleFileConfigRepository(appId, namespace, format);
}
Verify that this logic correctly handles all intended formats and that createPropertiesCompatibleFileConfigRepository
properly supports the appId
.
Consider adding unit tests to cover different ConfigFileFormat
scenarios.
85-85
: Consistent use of appId
in repository creation
The call to createConfigRepository(appId, namespace)
ensures that the appId
is consistently passed, improving the configurability across repositories.
91-91
: Creation of DefaultConfig
with appId
supports multi-app scenarios
Returning a DefaultConfig
instance initialized with appId
aligns with the goal of managing configurations per application.
94-97
: Overloaded createConfigFile
method enhances file configuration
By overloading createConfigFile
to include appId
, the configuration files can now be retrieved per application, supporting multiple appId
s.
104-105
: Consistent appId
usage in createConfigFile
method
The method correctly passes appId
to repository creation, ensuring that configuration files are properly associated with the specified application.
124-130
: Adjust repository creation logic for appId
inclusion
The createConfigRepository
method now accepts appId
, and calls to createLocalConfigRepository
and createRemoteConfigRepository
have been updated accordingly. Verify that all repository types correctly handle the appId
.
Ensure that any custom repositories or extensions also accommodate the new appId
parameter.
145-147
: Handle local mode appropriately with appId
When in local mode, LocalFileConfigRepository
is initialized with appId
:
return new LocalFileConfigRepository(appId, namespace);
Ensure that the local repository correctly uses appId
to locate the appropriate configuration files.
Consider testing the local mode to confirm that configurations are loaded as expected.
158-159
: Creation of RemoteConfigRepository
with appId
The method createRemoteConfigRepository
now includes appId
, facilitating remote configuration retrieval per application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepositoryTest.java (1)
167-167
: Consider enhancing test coverage for appId scenariosWhile the method call has been correctly updated to include the appId parameter, consider adding test cases for:
- Verifying the appId is correctly used in the ConfigMap update
- Testing error scenarios with invalid appIds
Example test cases to add:
@Test public void testOnRepositoryChangeWithInvalidAppId() throws ApiException { Properties newProperties = new Properties(); newProperties.setProperty(defaultKey, defaultValue); // Test with invalid appId String invalidAppId = ""; k8sConfigMapConfigRepository.onRepositoryChange(invalidAppId, someNamespace, newProperties); // Verify appropriate error handling verify(kubernetesManager, never()).updateConfigMap(anyString(), anyString(), anyMap()); } @Test public void testOnRepositoryChangeVerifyAppIdUsage() throws ApiException { Properties newProperties = new Properties(); newProperties.setProperty(defaultKey, defaultValue); k8sConfigMapConfigRepository.onRepositoryChange(someAppId, someNamespace, newProperties); // Verify appId is correctly used in ConfigMap update verify(kubernetesManager).updateConfigMap( eq(someAppId), // Verify exact appId is used anyString(), anyMap() ); }apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (1)
88-89
: Consider enhancing debug logging.The debug log could be more helpful by including the appId:
- logger.debug("Created a configuration repository of type [{}] for namespace [{}]", - configRepository.getClass().getName(), namespace); + logger.debug("Created a configuration repository of type [{}] for appId [{}] and namespace [{}]", + configRepository.getClass().getName(), appId, namespace);apollo-client/src/main/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepository.java (1)
Line range hint
59-68
: Critical: Constructor uses incorrect appId source.The constructor accepts an
appId
parameter but usesconfigUtil.getAppId()
when callingsetConfigMapName
. This could lead to configuration mismatches if the passedappId
differs from the one inconfigUtil
.Apply this fix:
public K8sConfigMapConfigRepository(String appId, String namespace, ConfigRepository upstream) { this.appId = appId; this.namespace = namespace; configUtil = ApolloInjector.getInstance(ConfigUtil.class); kubernetesManager = ApolloInjector.getInstance(KubernetesManager.class); k8sNamespace = configUtil.getK8sNamespace(); this.setConfigMapKey(configUtil.getCluster(), namespace); - this.setConfigMapName(configUtil.getAppId(), false); + this.setConfigMapName(appId, false); this.setUpstreamRepository(upstream); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepository.java
(3 hunks)apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java
(3 hunks)apollo-client/src/test/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepositoryTest.java
(2 hunks)
🧰 Additional context used
📓 Learnings (1)
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepository.java (1)
Learnt from: nobodyiam
PR: apolloconfig/apollo-java#79
File: apollo-client/src/main/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepository.java:156-162
Timestamp: 2024-10-26T12:49:07.584Z
Learning: In `K8sConfigMapConfigRepository#setUpstreamRepository`, when `upstreamConfigRepository` is `null`, we should return early without setting `upstream` to `null`, so the original upstream remains.
🔇 Additional comments (11)
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepositoryTest.java (1)
81-81
: LGTM: Constructor updated correctly to support multiple appIds
The constructor call has been properly updated to include the appId parameter, maintaining test coverage for the new signature.
apollo-client/src/main/java/com/ctrip/framework/apollo/spi/DefaultConfigFactory.java (7)
68-69
: LGTM! Clean backward compatibility implementation.
The delegation to the new overloaded method maintains backward compatibility while supporting multiple app IDs.
94-97
: LGTM! Consistent backward compatibility pattern.
The delegation pattern is consistently applied for ConfigFile creation.
99-100
: LGTM! Clean parameter propagation.
The method correctly forwards the appId parameter to the DefaultConfig constructor.
124-130
: LGTM! Consistent repository creation chain.
The appId parameter is properly propagated through the entire repository creation chain, maintaining the existing repository hierarchy while supporting multiple app IDs.
Also applies to: 140-147, 155-156, 158-159
163-164
: Verify ConfigService.getConfigFile implementation.
The code looks good, but we should verify that ConfigService.getConfigFile has been updated to handle the appId parameter correctly.
#!/bin/bash
# Description: Verify ConfigService implementation
# Test: Check if ConfigService has been updated to support appId
echo "Checking ConfigService implementation..."
ast-grep --pattern "class ConfigService {
$$$
public static ConfigFile getConfigFile(String appId, String namespace, ConfigFileFormat format) {
$$$
}
$$$
}"
183-183
: Question: Is appId parameter necessary?
The trimNamespaceFormat method accepts appId but doesn't use it in its implementation. Consider removing this parameter if it's not needed for the namespace format trimming logic.
#!/bin/bash
# Description: Check if appId is used in other implementations of trimNamespaceFormat
# Test: Search for other implementations that might use appId
echo "Checking for other trimNamespaceFormat implementations..."
rg -p "trimNamespaceFormat.*appId.*namespace.*format"
- String trimNamespaceFormat(String appId, String namespaceName, ConfigFileFormat format) {
+ String trimNamespaceFormat(String namespaceName, ConfigFileFormat format) {
104-118
: LGTM! Verify constructor signatures.
The appId parameter is consistently passed to all config file implementations. Let's verify that all referenced config file classes have been updated to accept appId in their constructors.
✅ Verification successful
All config file implementations correctly updated with appId parameter
Based on the verification results, all config file implementations (PropertiesConfigFile, XmlConfigFile, JsonConfigFile, YamlConfigFile, YmlConfigFile, and TxtConfigFile) have been properly updated to include the appId parameter in their constructors and correctly pass it to their parent classes. Each implementation follows the same pattern of accepting (String appId, String namespace, ConfigRepository configRepository) in their constructors.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that all config file implementations have been updated with appId parameter
# Test: Search for constructor definitions in config file classes
echo "Checking config file constructors..."
for class in PropertiesConfigFile XmlConfigFile JsonConfigFile YamlConfigFile YmlConfigFile TxtConfigFile; do
echo "Checking $class..."
ast-grep --pattern "class $class {
$$$
$class(String appId, String namespace, $_) {
$$$
}
$$$
}"
done
Length of output: 660
Script:
#!/bin/bash
# Let's try a different approach using ripgrep to find constructor definitions
echo "Checking PropertiesConfigFile constructor..."
rg "PropertiesConfigFile\(String\s+\w+,\s*String\s+\w+,\s*\w+\s+\w+\)" -A 2
echo -e "\nChecking XmlConfigFile constructor..."
rg "XmlConfigFile\(String\s+\w+,\s*String\s+\w+,\s*\w+\s+\w+\)" -A 2
echo -e "\nChecking JsonConfigFile constructor..."
rg "JsonConfigFile\(String\s+\w+,\s*String\s+\w+,\s*\w+\s+\w+\)" -A 2
echo -e "\nChecking YamlConfigFile constructor..."
rg "YamlConfigFile\(String\s+\w+,\s*String\s+\w+,\s*\w+\s+\w+\)" -A 2
echo -e "\nChecking YmlConfigFile constructor..."
rg "YmlConfigFile\(String\s+\w+,\s*String\s+\w+,\s*\w+\s+\w+\)" -A 2
echo -e "\nChecking TxtConfigFile constructor..."
rg "TxtConfigFile\(String\s+\w+,\s*String\s+\w+,\s*\w+\s+\w+\)" -A 2
Length of output: 2701
Script:
#!/bin/bash
# Let's check the remaining config file implementations that weren't found in the previous search
echo "Checking PropertiesConfigFile implementation..."
rg "class PropertiesConfigFile" -A 10
echo -e "\nChecking XmlConfigFile implementation..."
rg "class XmlConfigFile" -A 10
echo -e "\nChecking JsonConfigFile implementation..."
rg "class JsonConfigFile" -A 10
Length of output: 8075
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepository.java (3)
47-47
: LGTM: Appropriate field addition for multi-app support.
The addition of the final appId
field aligns with the PR's objective of supporting multiple app IDs and follows good encapsulation practices.
241-241
: LGTM: Proper propagation of appId to listeners.
The change correctly propagates the appId to repository change listeners, maintaining consistency with the multi-app support objective.
Line range hint 59-241
: Verify impact on monitoring metrics.
As mentioned in the PR discussion, this change might affect monitoring metrics from PR #74. The addition of multiple appId support could require adjustments to metric collection and reporting.
Let's verify the metric collection points:
Consider these architectural recommendations:
- Ensure metrics are properly tagged with appId for accurate monitoring
- Update dashboards and alerts to handle multi-app scenarios
- Document the changes in monitoring behavior for operators
✅ Verification successful
Metrics implementation is sufficient for multi-app support
The current implementation of metrics in K8sConfigMapConfigRepository is consistent with other repositories and properly handles multi-app scenarios:
- Transaction metrics already include configMapName which contains the appId (via
APOLLO_CONFIG_CACHE + appId
format) - Error tracking includes detailed context through ExceptionUtil
- The implementation follows the same pattern as RemoteConfigRepository which successfully handles multi-app scenarios
The metrics will naturally segment by app since the configMapName (which includes appId) is added as transaction data in both create and persist operations.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for metric collection points that might need updating
rg -l "Tracer.logEvent|Tracer.logError|Tracer.newTransaction" | grep -v "test"
Length of output: 1554
Script:
#!/bin/bash
# Let's examine the actual metric collection points in K8sConfigMapConfigRepository
rg -A 5 "Tracer\.(logEvent|logError|newTransaction)" apollo-client/src/main/java/com/ctrip/framework/apollo/internals/K8sConfigMapConfigRepository.java
# Let's also check how other repositories handle appId in metrics
rg -A 5 "Tracer\.(logEvent|logError|newTransaction).+appId" --type java
Length of output: 4272
@Override | ||
public void onRepositoryChange(String namespace, Properties newProperties) { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Fix repository change notification handling.
The code has multiple issues with the onRepositoryChange
methods:
- The empty implementation could silently drop notifications
- Having both methods violates the Liskov Substitution Principle
- The old method should be marked as deprecated if being replaced
Apply this fix:
- @Override
- public void onRepositoryChange(String namespace, Properties newProperties) {
-
- }
+ /**
+ * @deprecated Use {@link #onRepositoryChange(String, String, Properties)} instead
+ */
+ @Deprecated
+ @Override
+ public void onRepositoryChange(String namespace, Properties newProperties) {
+ onRepositoryChange(this.appId, namespace, newProperties);
+ }
/**
* Update the memory
*
* @param namespace the namespace of this repository change
* @param newProperties the properties after change
*/
@Override
public void onRepositoryChange(String appId, String namespace, Properties newProperties) {
if (newProperties == null || newProperties.equals(configMapProperties)) {
return;
}
Properties newFileProperties = propertiesFactory.getPropertiesInstance();
newFileProperties.putAll(newProperties);
updateConfigMapProperties(newFileProperties, upstream.getSourceType());
this.fireRepositoryChange(appId, namespace, newProperties);
}
Also applies to: 234-241
@TerryLam2010 As this pull request is quite large and already takes a lot of time in reviewing. I suggest scheduling an online meeting for a thorough, quick review. If that works for you, please email me at [email protected] to arrange a suitable time. |
What's the purpose of this PR
add multiple appId pull into config
see #66
Which issue(s) this PR fixes:
Fixes #
Follow this checklist to help us incorporate your contribution quickly and easily:
Summary by CodeRabbit
New Features
appId
parameter across various configuration classes, allowing configuration queries and changes to be associated with a specific application ID.getAccessKeySecret(String appId)
to manage access keys based on application IDs.appId
.Changes in APIs
appId
.Refactor
appId
.These changes enhance the ability to manage and query configurations on a per-application basis, improving flexibility and granularity in configuration management.