Problem:
In the latest version of the AWS JAVA V2 library, a new field called numAttempts has been introduced in exceptions. The retryPolicyDisallowedRetryException function within the RetryableStageHelper class updates the numAttempts field of an existing exception by rebuilding the exception using the .toBuilder() method of lastException.
https://github.com/aws/aws-sdk-java-v2/pull/5834/files#diff-ed639f79eb469d6710b59bee206eeedf3f5764e57ed4871e6b3092cc04d90ee6R168
However, the S3EncryptionClientException does not conform to the typical AWS exception pattern and lacks a builder function. Consequently, the builder function of SdkClientException is used instead (It is the parent of S3EncryptionClientException), resulting in the creation of a new SdkClientException. This leads to the thrown exception being altered.
example, the below test will fail
@Test
fun `should not change the original exception type`() = runTest {
val encryptionException = S3EncryptionClientException("message", RuntimeException("cause"))
val newException = encryptionException.toBuilder().build()
assertThat(encryptionException.javaClass).isEqualTo(newException.javaClass)
}
Solution:
Implement the toBuilder() in the S3EncryptionClientException like others
Problem:
In the latest version of the AWS JAVA V2 library, a new field called numAttempts has been introduced in exceptions. The
retryPolicyDisallowedRetryExceptionfunction within theRetryableStageHelperclass updates thenumAttemptsfield of an existing exception by rebuilding the exception using the.toBuilder()method oflastException.https://github.com/aws/aws-sdk-java-v2/pull/5834/files#diff-ed639f79eb469d6710b59bee206eeedf3f5764e57ed4871e6b3092cc04d90ee6R168
However, the S3EncryptionClientException does not conform to the typical AWS exception pattern and lacks a builder function. Consequently, the builder function of SdkClientException is used instead (It is the parent of S3EncryptionClientException), resulting in the creation of a new SdkClientException. This leads to the thrown exception being altered.
example, the below test will fail
Solution:
Implement the toBuilder() in the S3EncryptionClientException like others