Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detected an instance of Random/SplittableRandom class in the image heap #40785

Open
3 tasks
parasjain27031994 opened this issue Jun 24, 2024 · 3 comments
Open
3 tasks
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@parasjain27031994
Copy link

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.

To Reproduce
Steps to reproduce the behavior:

Code Snippet
Snippets from pom.xml

 <dependency>
            <groupId>io.quarkiverse.azureservices</groupId>
            <artifactId>quarkus-azure-http-client-vertx</artifactId>
            <version>1.0.4</version>
        </dependency>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-messaging-eventhubs</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.azure</groupId>
                    <artifactId>azure-core-http-netty</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Declaration of Azure EventHub producer :

@Singleton
public class EventHubConfig {

    @Inject
    EventHubCredentialService eventHubCredentialService;

    private EventHubProducerClient eventHubProducerClient;

    @Produces
    public EventHubProducerClient eventHubProducerClient() {
        if (eventHubProducerClient == null) {
            EventHubDetails eventHubDetails = eventHubCredentialService.getEvenHubDetails();
            eventHubProducerClient = new EventHubClientBuilder()
                    .connectionString(eventHubDetails.connectionString(), eventHubDetails.eventHubName())
                    .retryOptions(
                            new AmqpRetryOptions()
                                    .setDelay(Duration.ofSeconds(2))
                                    .setMaxRetries(3)
                                    .setMode(AmqpRetryMode.EXPONENTIAL)
                    )
                    .buildProducerClient();
        }
        return eventHubProducerClient;
    }

    @PreDestroy
    public void closeEventHubProducerClient() {
        if (eventHubProducerClient != null) {
            eventHubProducerClient.close();
        }
    }

Expected behavior
Since Azure SDK is compatible with GraalVM, the build should succeed.

Screenshots
N/A

Setup (please complete the following information):

  • OS: Windows 11
  • IDE: IntelliJ
  • Library/Libraries: [e.g. com.azure:azure-core:1.16.0 (groupId:artifactId:version)]
  • Java version: 21
  • App Server/Environment: IDE plugin
  • Frameworks: Quarkus

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

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Jun 24, 2024
Copy link

@anuchandy @conniey @lmolkova

@github-actions github-actions bot added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Jun 24, 2024
Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@anuchandy
Copy link
Member

Hi @parasjain27031994, unlike the SDKs in azure-sdk-for-java repo, the Azure/qpid-proton-j-extensions does not ship with the resources\application.properties with potential entries. To resolve this, we suggest adding the qpid-proton-j-extensions package name entry to your application’s application.properties as shown below -

quarkus.native.additional-build-args=--initialize-at-run-time=com.microsoft.azure.proton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants