aws-sdk-kotlin: EOFException after upgrading AWS SDK Kotlin to 0.22.1-beta
Describe the bug
After upgrading the AWS SDK Kotlin from 0.22.0-beta to 0.22.1-beta in a Spring Boot application, I am encountering an EOFException related to OkHttp when using the SDK to upload files to Amazon S3 while processing multiple concurrent requests using async. Rolling back to 0.22.0-beta resolves the issue.
exception is below.
Caused by: java.io.EOFException: \n not found: limit=0 content=… at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:332) ~[okio-jvm-3.3.0.jar:na] at okhttp3.internal.http1.HeadersReader.readLine(HeadersReader.kt:29) ~[okhttp-jvm-5.0.0-alpha.11.jar:na] at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:179) ~[okhttp-jvm-5.0.0-alpha.11.jar:na] … 16 common frames omitted
Expected behavior
No EOFException should be thrown, and the application should be able to upload files to Amazon S3 without any issues while processing multiple concurrent requests.
Current behavior
The application throws an EOFException when trying to upload files to Amazon S3 after upgrading the AWS SDK Kotlin to 0.22.1-beta and processing multiple concurrent requests using async.
Steps to Reproduce
Upgrade the AWS SDK Kotlin to 0.22.1-beta. Configure the S3 client in a Spring Boot application using the provided configuration code. Use the provided upload logic to upload a file to Amazon S3. Observe the EOFException being thrown.
@Configuration
@EnableConfigurationProperties(StorageProperties::class)
class StorageConfiguration(private val properties: StorageProperties) {
@Bean(destroyMethod = "close")
fun s3Client() = S3Client {
region = properties.region
credentialsProvider = StaticCredentialsProvider {
accessKeyId = properties.accessKey
secretAccessKey = properties.secretKey
}
}
}
@ConfigurationProperties(prefix = "aws.s3")
data class StorageProperties(
val bucketName: String,
val accessKey: String,
val secretKey: String,
val region: String,
val keyPrefix: String
)
@Service
class StorageService(
private val client: S3Client,
private val properties: StorageProperties,
) {
suspend fun upload(binary: ByteArray, contentType: String): ByteArray {
client.putObject {
bucket = properties.bucketName
key ="path/to/my/file"
body = ByteStream.fromBytes(binary)
this.contentType = contentType
}
return binary
}
}
Possible Solution
No response
Context
No response
AWS Kotlin SDK version used
0.22.1-beta, kotlin 1.8.20 and 1.8.21 both versions occured
Platform (JVM/JS/Native)
JVM
Operating System and version
The application is built using the paketo buildpack with JDK 20 and run as a Docker image.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 15 (6 by maintainers)
There was a fix to do the retry. After that occurrence was significantly reduced. But not completely 👀