If log4j.properties file is present, S3AsyncClient throws an exception when calling putObject
Security issue notifications
If you discover a potential security issue in the Amazon S3 Encryption Client we ask that you notify AWS Security via our vulnerability reporting page. Please do not create a public GitHub issue.
Problem:
I downloaded and built the amazon-s3-encryption-client-java-main 3.3.1 package. I copied it and the dependencies to a machine and ran the software.amazon.encryption.s3.examples.AsyncClientExample and added slf4j-reload4j-1.7.36.jar and reload4j-1.2.25.jar It ran fine. I then created a log4j.properties file with the content below in the target/classes directory and it threw the exception below - although it seemed to work anyway. However, the program exits at that point and I don't know if the S3EncryptionClient remains usable afterwards.
log4j.properties: log4j.rootLogger=ERROR,stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
Exception stack trace: Upstream delivered more data than requested. Resetting state to prevent a frozen stream. java.lang.IllegalStateException at software.amazon.awssdk.utils.async.BaseSubscriberAdapter.ensureUpstreamDemandExists(BaseSubscriberAdapter.java:296) at software.amazon.awssdk.utils.async.BaseSubscriberAdapter.handleUpstreamDemandState(BaseSubscriberAdapter.java:230) at software.amazon.awssdk.utils.async.BaseSubscriberAdapter.handleStateUpdate(BaseSubscriberAdapter.java:180) at software.amazon.awssdk.utils.async.BaseSubscriberAdapter$1.request(BaseSubscriberAdapter.java:109) at software.amazon.awssdk.http.nio.netty.internal.nrs.HandlerSubscriber.maybeRequestMore(HandlerSubscriber.java:303) at software.amazon.awssdk.http.nio.netty.internal.nrs.HandlerSubscriber.maybeStart(HandlerSubscriber.java:238) at software.amazon.awssdk.http.nio.netty.internal.nrs.HandlerSubscriber.provideSubscription(HandlerSubscriber.java:225) at software.amazon.awssdk.http.nio.netty.internal.nrs.HandlerSubscriber.access$000(HandlerSubscriber.java:41) at software.amazon.awssdk.http.nio.netty.internal.nrs.HandlerSubscriber$1.run(HandlerSubscriber.java:213) at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:998) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at java.base/java.lang.Thread.run(Thread.java:840)
Solution:
It should not throw an exception. I don't
Out of scope:
Is there anything the solution will intentionally NOT address?
Hi, we see the same error when using this library. We see the application still running and the put is still working, but the logs not readable anymore (2k error logs) and the cloudwatch costs are increasing.
Hey @andrewnmiferreira,
Thank you for reaching out. What version of the AWS SDK are you using? Could you try upgrading to the recently released S3EC version 3.3.2 and see if that improves the situation? Let us know, thanks!
Updated to S3EC 3.3.2 and used the AWS SDK versions specified by that pom file (2.31.14). Unsurprisingly, it made no difference.
Hey @andrewnmiferreira,
We identified an issue with the Subscriber implementation and have released a fix in version 3.3.5. Can you upgrade to this version and let us know if this fixes the problem? Thanks!