aws / aws-sdk-java

The official AWS SDK for Java 1.x (In Maintenance Mode, End-of-Life on 12/31/2025). The AWS SDK for Java 2.x is available here: https://github.com/aws/aws-sdk-java-v2/
https://aws.amazon.com/sdkforjava
Apache License 2.0
4.13k stars 2.83k forks source link

aws-java-sdk-bundle shades publicly exposed methods. #2024

Closed smart-nick closed 5 years ago

smart-nick commented 5 years ago

aws-java-sdk-bundle has this relocation pattern:

<relocation>
    <pattern>org.apache.commons.logging</pattern>
    <shadedPattern>com.amazonaws.thirdparty.apache.logging</shadedPattern>
</relocation>

The problem is, this SDK has publicly exposed methods that use org.apache.commons.logging. Specifically, the IOUtils.closeQuiety(Closeable is, Log log) takes a log parameter from that library. When it gets shaded, a java.lang.NoSuchMethodError is thrown since you are passing in org.apache.commons.logging.Log instead of com.amazonaws.thirdparty.apache.logging.Log. I ran into this issue with the extended sqs client lib; there is an issue here for that. I think it would be preferable to remove the relocation pattern I listed above from aws-java-sdk-bundle so that the shading only effects the internals of the SDK instead of publicly exposed methods.

debora-ito commented 5 years ago

Hi @smart-nick, I understand the issue but unfortunately we cannot make this change without breaking backward compatibility, we'll have to keep shading all the dependencies, even the ones exposed directly.

A possible workaround may be shading the SDK when working with the extended sqs client lib.

debora-ito commented 5 years ago

Closing this, feel free to reopen if you have further questions.

emoods commented 4 years ago

here some workaround for people like me that try to solve this problem:

use this relocation on your final jar builder in maven. There is a similar solution using gradle but I don't know the syntax. This at least worked for me but as described this is a dirty hack.

<configuration>
  <relocations>
      <relocation>
           <pattern>org.apache.commons.logging</pattern>
           <shadedPattern>com.amazonaws.thirdparty.apache.logging</shadedPattern>
       </relocation>
     </relocations>