Skip to content

Commit

Permalink
fix: s3 regional endpoint cover version upgrade scenario (#1543)
Browse files Browse the repository at this point in the history
  • Loading branch information
yitingb authored Oct 11, 2023
1 parent ab75202 commit 2892a7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public DeviceConfiguration(Kernel kernel) {
handleLoggingConfig();
getComponentStoreMaxSizeBytes().dflt(COMPONENT_STORE_MAX_SIZE_DEFAULT_BYTES);
getDeploymentPollingFrequencySeconds().dflt(DEPLOYMENT_POLLING_FREQUENCY_DEFAULT_SECONDS);
if (System.getProperty(S3_ENDPOINT_PROP_NAME) != null
&& System.getProperty(S3_ENDPOINT_PROP_NAME).equalsIgnoreCase(S3EndpointType.REGIONAL.name())) {
gets3EndpointType().withValue(S3EndpointType.REGIONAL.name());
}
// reset the cache when device configuration changes
onAnyChange((what, node) -> deviceConfigValidateCachedResult.set(null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void clearCache() {
if(cachedClient != null) {
cachedClient.close();
}
System.clearProperty(S3_ENDPOINT_PROP_NAME);
}

@Test
Expand Down Expand Up @@ -110,7 +111,7 @@ void GIVEN_valid_configuration_WHEN_updated_THEN_new_added() throws DeviceConfig
@Test
void GIVEN_valid_configuration_WHEN_get_client_for_region_THEN_clients_cached() {
S3SdkClientFactory factory = new S3SdkClientFactory(deviceConfig, credentialProvider);

factory.handleRegionUpdate();
try (S3Client client = factory.getClientForRegion(Region.US_WEST_2)) {
assertThat("has client", client, is(notNullValue()));
assertThat(S3SdkClientFactory.clientCache, hasEntry(is(Region.US_WEST_2), is(client)));
Expand Down

0 comments on commit 2892a7c

Please sign in to comment.