This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.25k
stars
1.93k
forks
source link
Detected an instance of Random/SplittableRandom class in the image heap #40785
Describe the bug
While trying to build a native image for a Quarkus based project, the build is failing with Error: "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."
Exception or Stack Trace
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Unsupported features in 2 methods
Detailed message:
Error: 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. If these objects should not be stored in the image heap, you can use
'--trace-object-instantiation=java.security.SecureRandom'
to find classes that instantiate these objects. Once you found such a class, you can mark it explicitly for run time initialization with
'--initialize-at-run-time=<culprit>'
to prevent the instantiation of the object.
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.
Trace: Object was reached by
trying to constant fold static field com.microsoft.azure.proton.transport.proxy.impl.DigestProxyChallengeProcessorImpl.SECURE_RANDOM
at com.microsoft.azure.proton.transport.proxy.impl.DigestProxyChallengeProcessorImpl.computeDigestAuthHeader(DigestProxyChallengeProcessorImpl.java:143)
parsing method com.microsoft.azure.proton.transport.proxy.impl.DigestProxyChallengeProcessorImpl.computeDigestAuthHeader(DigestProxyChallengeProcessorImpl.java:116) reachable via the parsing context
at static root method.(Unknown Source)
Error: 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. If these objects should not be stored in the image heap, you can use
'--trace-object-instantiation=java.security.SecureRandom'
to find classes that instantiate these objects. Once you found such a class, you can mark it explicitly for run time initialization with
'--initialize-at-run-time=<culprit>'
to prevent the instantiation of the object.
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.
Trace: Object was reached by
trying to constant fold static field com.microsoft.azure.proton.transport.ws.impl.Utils.SECURE_RANDOM
at com.microsoft.azure.proton.transport.ws.impl.Utils.getSecureRandom(Utils.java:20)
parsing method com.microsoft.azure.proton.transport.ws.impl.Utils.getSecureRandom(Utils.java:20) reachable via the parsing context
at static root method.(Unknown Source)
at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.constraints.UnsupportedFeatures.report(UnsupportedFeatures.java:129)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:809)
... 6 more
2m 42s.
Additional context
The project uses Azure EventHub library to produce messages, running on AWS Lambda function.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
Describe the bug While trying to build a native image for a Quarkus based project, the build is failing with Error: "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."
Exception or Stack Trace
To Reproduce Steps to reproduce the behavior:
Code Snippet Snippets from pom.xml
Declaration of Azure EventHub producer :
Expected behavior Since Azure SDK is compatible with GraalVM, the build should succeed.
Screenshots N/A
Setup (please complete the following information):
Additional context The project uses Azure EventHub library to produce messages, running on AWS Lambda function.
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report