aws-sdk-java-v2
aws-sdk-java-v2 copied to clipboard
Native image build fails due to CachedSupplier/SplittableRandom
Describe the bug
Building a native image with Graal fails with the latest AWS SDK 2.17.238 The issue did not yet exist with AWS SDK 2.16.51.
I was able to work around it by using --initialize-at-run-time=software.amazon.awssdk.utils.cache.CachedSupplier
.
Expected Behavior
No error
Current Behavior
Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace:
at parsing software.amazon.awssdk.utils.cache.CachedSupplier.jitterTime(CachedSupplier.java:326)
Reproduction Steps
Can be reproduced with Graal 21.3.0 and 'GraalVM 22.1.0.0-Final Java 17 Mandrel Distribution'.
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.17.238
JDK version used
11 and 17
Operating System and version
Linux
Hello @MarkusKramer ,
I wasn't able to reproduce this issue. Building a native image does work with the Java AWS SDK 2.17.238 and GraalVM 22.1.0 Java 17 CE on my end.
Could you elaborate the reproduction steps?
You can also find guided documentation for GraalVM Native Image support for Java AWS SDK v2 here: https://aws.amazon.com/blogs/developer/graalvm-native-image-support-in-the-aws-sdk-for-java-2-x/
Best,
Yasmine
Hi. Okay interesting. Maybe an important aspect is that I'm using the url-connection-client (because I'm using the AWS SDK with Quarkus). I'm including the SDK like this in my Gradle build.gradle.kt file:
implementation(enforcedPlatform("software.amazon.awssdk:bom:2.17.238"))
implementation("software.amazon.awssdk:url-connection-client")
fun awsImplementation(artifactId: String) {
implementation("software.amazon.awssdk:$artifactId") {
exclude("software.amazon.awssdk", "netty-nio-client")
exclude("software.amazon.awssdk", "apache-client")
}
}
awsImplementation("s3")
awsImplementation("sts")
Hope that helps to reproduce. At least one other person also got the same issue as reported here https://github.com/quarkusio/quarkus/issues/14904#issuecomment-1057799863
Hello @MarkusKramer,
Thank you very much for your response and for sharing your build.gradle.kt file. We have added this bug fix to our backlog.
Best,
Yasmine
Thanks! Yes, I also have the same problem, my relateddependencies are:
implementation("software.amazon.awssdk:url-connection-client:${awsPluginVersion}") {
exclude(group: "software.amazon.awssdk", module: "netty-nio-client")
exclude(group: "software.amazon.awssdk", module: "apache-client")
}
implementation("software.amazon.awssdk:apache-client:${awsPluginVersion}") {
exclude(group: "commons-logging", module: "commons-logging")
}
...
testImplementation "software.amazon.awssdk:netty-nio-client:${awsPluginVersion}"
Hello @MarkusKramer !
We think we might have a fix for this issue that would make it so -initialize-at-run-time=software.amazon.awssdk.utils.cache.CachedSupplier
is not required, but I cannot seem to reproduce the problem described in this issue. Therefore I cannot really test our solution.
I have put together a small demo project to try to reproduce it, using the same Gradle dependencies. I have tried to compile and run this small project with GraalVM 22.1.0
and 22.2
both with java 11 and 17. All worked fine on my end.
Again, thanks for submitting this issue to our attention!
I am also getting this issue
Having this issue as well.
To reproduce:
- Checkout the quarked-ddns project
- Remove --initialize-at-runtime value in this file https://github.com/zeppelinux/quarked-ddns/blob/main/src/main/resources/application.properties
- See native build fails with the reported exception.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.