Skip to content

Commit

Permalink
fix: correct conditional for S3CrtAsyncClientAutoConfiguration (#970)
Browse files Browse the repository at this point in the history
Co-authored-by: Iuliia Sobolevska <isobolevska@netflix.com>
  • Loading branch information
iuliiasobolevska and iuliiasobolevska authored Dec 1, 2023
1 parent bea0e01 commit de5d2f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @since 3.0
*/
@AutoConfiguration
@ConditionalOnClass({ S3Client.class })
@ConditionalOnClass({ S3Client.class, S3AsyncClient.class })
@EnableConfigurationProperties({ S3Properties.class })
@ConditionalOnProperty(name = "spring.cloud.aws.s3.enabled", havingValue = "true", matchIfMissing = true)
@AutoConfigureBefore(S3TransferManagerAutoConfiguration.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.test.util.ReflectionTestUtils;
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
Expand Down Expand Up @@ -92,6 +93,14 @@ void setsPropertiesOnClient() {
});
}

@Test
void handlesMissingS3AsyncClient() {
contextRunner.withClassLoader(new FilteredClassLoader(S3AsyncClient.class)).run(context -> {
assertThat(context).hasNotFailed();
assertThat(context).doesNotHaveBean(S3AsyncClient.class);
});
}

private static S3NativeClientConfiguration s3NativeClientConfiguration(S3AsyncClient client) {
ConfiguredAwsClient configuredClient = new ConfiguredAwsClient(client);
SdkAsyncHttpClient sdkAsyncHttpClient = configuredClient.getAsyncHttpClient();
Expand Down

0 comments on commit de5d2f3

Please sign in to comment.