Azure / azure-sdk-for-java

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.33k stars 1.97k forks source link

[BUG] java.lang.ExceptionInInitializerError #40685

Closed peter6053 closed 3 months ago

peter6053 commented 3 months ago

Describe the bug Getting this bug , crush in android app java.lang.ExceptionInInitializerError Exception or Stack Trace Add the exception log and stack trace if available java.lang.ExceptionInInitializerError at com.azure.core.implementation.ReflectionUtils.getLookupToUse(ReflectionUtils.java:119) at com.azure.core.util.ExpandableStringEnum.getDefaultConstructor(ExpandableStringEnum.java:88) at com.azure.core.util.ExpandableStringEnum.$r8$lambda$SMtq8BJfA6t_qJk1WfhslLPTCwc(Unknown Source:0) at com.azure.core.util.ExpandableStringEnum$$ExternalSyntheticLambda1.apply(Unknown Source:2) at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1716) at com.azure.core.util.ExpandableStringEnum.fromString(ExpandableStringEnum.java:68) at com.azure.core.http.HttpHeaderName.fromString(HttpHeaderName.java:60) at com.azure.core.http.HttpHeaderName.(HttpHeaderName.java:88) at com.azure.core.http.HttpHeaderName.fromString(HttpHeaderName.java:56) at com.azure.storage.blob.implementation.util.ModelHelper.(ModelHelper.java:65) at com.azure.storage.blob.implementation.util.ModelHelper.determineAuthorityIsIpStyle(ModelHelper.java:75) at com.azure.storage.blob.BlobUrlParts.parse(BlobUrlParts.java:371) at com.azure.storage.blob.BlobServiceClientBuilder.endpoint(BlobServiceClientBuilder.java:171) To Reproduce I have android studion on mac Android Studio Flamingo | 2022.2.1 Patch 2 This is the vesrion implementation "com.azure:azure-storage-blob:12.21.0" Code Snippet Add the code snippet that causes the issue. private fun createBlobServiceClient(): BlobServiceClient? { val connectionString = "putyours"

    return try {
        BlobServiceClientBuilder()
            .connectionString(connectionString)
            .httpClient(HttpClient.createDefault())
            .buildClient()
    } catch (e: Exception) {
        Log.e("BlobServiceClient", "Error creating BlobServiceClient: ${e.message}", e)
        null
    }
}

Expected behavior A clear and concise description of what you expected to happen. where you initialzied it crashes the app

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

Additional context Add any other context about the problem here.

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

alzimmermsft commented 3 months ago

Hi @peter6053, thank you for filing this issue.

The SDKs provided by azure-sdk-for-java don't have guaranteed support for Android, but we try to support it as best we can (given many of the dependencies we use don't work with Android).

What you're running into here is an issue with how reflection works with in Android vs Java. This was addressed in a version of azure-core newer than the version of azure-storage-blob you're using:

https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/CHANGELOG.md#1440-2023-10-06

Upgrading to azure-storage-blob 12.24.1 or later should resolve this issue.

github-actions[bot] commented 3 months ago

Hi @peter6053. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.