Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses load-balancing behavior in Spring Cloud Azure App Configuration refresh flows to ensure configuration and feature-flag refresh use consistent client selection and to avoid dropping replicas from the active rotation.
Changes:
- Adjusts
ConnectionManager#getNextActiveClientto rotate clients for round-robin load balancing instead of removing them from the active list. - Updates refresh logic to select clients consistently between configuration refresh checks and feature-flag refresh checks.
- Removes now-unused “current replica” tracking and updates tests and changelog accordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManager.java | Changes load-balancing selection to round-robin rotation; removes unused replica tracking. |
| sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/AppConfigurationReplicaClientFactory.java | Removes API used for tracking “current” replica client. |
| sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/AppConfigurationRefreshUtil.java | Aligns refresh retry/client selection behavior for configuration vs feature-flag checks. |
| sdk/spring/spring-cloud-azure-appconfiguration-config/src/test/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManagerTest.java | Updates expectations for new round-robin behavior. |
| sdk/spring/spring-cloud-azure-appconfiguration-config/src/test/java/com/azure/spring/cloud/appconfiguration/config/implementation/AppConfigurationRefreshUtilTest.java | Removes obsolete verification tied to removed “current client” API. |
| sdk/spring/spring-cloud-azure-appconfiguration-config/CHANGELOG.md | Adds a bug-fix entry describing the load-balancing/feature-flag refresh fix. |
...in/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManager.java
Outdated
Show resolved
Hide resolved
...ure/spring/cloud/appconfiguration/config/implementation/AppConfigurationRefreshUtilTest.java
Show resolved
Hide resolved
...ava/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManagerTest.java
Outdated
Show resolved
Hide resolved
sdk/spring/spring-cloud-azure-appconfiguration-config/CHANGELOG.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
...in/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManager.java
Outdated
Show resolved
Hide resolved
…/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManager.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
...ava/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManagerTest.java
Outdated
Show resolved
Hide resolved
...m/azure/spring/cloud/appconfiguration/config/implementation/AppConfigurationRefreshUtil.java
Show resolved
Hide resolved
…/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManagerTest.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
sdk/spring/spring-cloud-azure-appconfiguration-config/src/main/java/com/azure/spring/cloud/appconfiguration/config/implementation/ConnectionManager.java:102
- In getNextActiveClient, the local variable name
clientsshadows the instance fieldclients, which makes the control flow harder to follow and easy to misread (especially since this method also mutatesactiveClients). Rename the local variable to something likeavailableClients(or similar) to avoid shadowing and improve readability.
if (useLastActive) {
List<AppConfigurationReplicaClient> clients = getAvailableClients();
for (AppConfigurationReplicaClient client: clients) {
if (client.getEndpoint().equals(lastActiveClient)) {
return client;
| // Monitor is disabled | ||
| RefreshEventData eventData = new AppConfigurationRefreshUtil().refreshStoresCheck(clientFactoryMock, | ||
| Duration.ofMinutes(10), | ||
| (long) 60, replicaLookUpMock); | ||
| assertFalse(eventData.getDoRefresh()); | ||
| verify(clientFactoryMock, times(1)).setCurrentConfigStoreClient(Mockito.eq(endpoint), Mockito.eq(endpoint)); | ||
| verify(clientOriginMock, times(0)).getWatchKey(Mockito.anyString(), Mockito.anyString(), | ||
| Mockito.any(Context.class)); | ||
| } |
There was a problem hiding this comment.
The tests no longer assert the key behavior this PR is fixing: configuration refresh should select a client with useLastActive=false, and feature-flag refresh should reuse the same client with useLastActive=true (especially in the single-client load-balancing case where activeClients is emptied by the config check). Please strengthen/add a regression test that verifies getNextActiveClient(endpoint, false) is used for configuration and getNextActiveClient(endpoint, true) for feature flags, and that both checks operate on the same client in the single-store scenario.
Description
currentReplicavariable. From the previous change toactiveClient.Note: A second PR will be created to randomize the active replica list for load balancing.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines