Skip to content

[BUG]BlobServiceClientBuilder’s buildClient method does not return or terminate the thread. #47541

@abhishekpankaj54

Description

@abhishekpankaj54

Describe the bug
When I run the below line of code it does not return any thing(exception/logs or etc) and it exits the calling thread.
BlobServiceClient blobServiceClient = (new BlobServiceClientBuilder()).endpoint(endpoint).credential(credential).buildClient();

Means it does not come back and releases the thread.

How did I verify this? I placed the line inside a try block and added a log statement after the call, but it never threw an exception and didn’t even write the logs.

Exception or Stack Trace
No error /exception

To Reproduce
use the below code:

public BlobBatchClient getBlobBatchClient(String storageAccountName) {
        log.debug("DEBUG_LOG inside getBlobBatchClient storageAccountName: {}",storageAccountName);
        StorageAccount storageAccount = getStorageAccountByName(storageAccountName);

        log.debug("DEBUG_LOG after  getStorageAccountByName");
        if (storageAccount !=null)
        {
            if (storageAccount.getKeys() != null)
            {
                log.debug("DEBUG_LOG inside getBlobBatchClient and checking keys{}",storageAccount.getKeys().get(0).value());
            }
            else {
                log.debug("DEBUG_LOG inside getBlobBatchClient storageAccount.getKeys() is null");
            }

        }
        else
        {
            log.debug("DEBUG_LOG inside getBlobBatchClient storageAccount is null");
        }
        String endpointString;
        if (getCloudProvider() == Provider.AZURE_GOV) {
            endpointString = ENDPOINTGOV_STRING;
        } else
            endpointString = ENDPOINT_STRING;
        String endpoint = String.format(Locale.ROOT, endpointString, storageAccountName);
        log.debug("DEBUG_LOG inside getBlobBatchClient endpoint{}",endpoint);
        StorageSharedKeyCredential credential = new StorageSharedKeyCredential(storageAccountName, storageAccount.getKeys().get(0).value());
        log.debug("DEBUG_LOG after  getStorageAccountByName credential{}",credential.getAccountName());
        BlobServiceClient blobServiceClient=null;
        try {
           
----------------till this it works---------------- 
            blobServiceClient = (new BlobServiceClientBuilder()).endpoint(endpoint).credential(credential).buildClient();  --------> when it reaches here no output and calling thread gets exit.
            log.debug("DEBUG_LOG after  getStorageAccountByName blobServiceClient{}", credential.getAccountName());
        } catch (Exception e) {
            log.debug("DEBUG_LOG inside getBlobBatchClient inside catch msg : {}",e.getMessage());
        }
        log.debug("DEBUG_LOG inside getBlobBatchClient before return");
        return new BlobBatchClientBuilder(blobServiceClient).buildClient();

    }

Code Snippet

public BlobBatchClient getBlobBatchClient(String storageAccountName) {
        log.debug("DEBUG_LOG inside getBlobBatchClient storageAccountName: {}",storageAccountName);
        StorageAccount storageAccount = getStorageAccountByName(storageAccountName);

        log.debug("DEBUG_LOG after  getStorageAccountByName");
        if (storageAccount !=null)
        {
            if (storageAccount.getKeys() != null)
            {
                log.debug("DEBUG_LOG inside getBlobBatchClient and checking keys{}",storageAccount.getKeys().get(0).value());
            }
            else {
                log.debug("DEBUG_LOG inside getBlobBatchClient storageAccount.getKeys() is null");
            }

        }
        else
        {
            log.debug("DEBUG_LOG inside getBlobBatchClient storageAccount is null");
        }
        String endpointString;
        if (getCloudProvider() == Provider.AZURE_GOV) {
            endpointString = ENDPOINTGOV_STRING;
        } else
            endpointString = ENDPOINT_STRING;
        String endpoint = String.format(Locale.ROOT, endpointString, storageAccountName);
        log.debug("DEBUG_LOG inside getBlobBatchClient endpoint{}",endpoint);
        StorageSharedKeyCredential credential = new StorageSharedKeyCredential(storageAccountName, storageAccount.getKeys().get(0).value());
        log.debug("DEBUG_LOG after  getStorageAccountByName credential{}",credential.getAccountName());
        BlobServiceClient blobServiceClient=null;
        try {
           
**----------------till this it works----------------** ****
            blobServiceClient = (new BlobServiceClientBuilder()).endpoint(endpoint).credential(credential).buildClient();  --------> when it reaches here no output and calling thread gets exit.
            log.debug("DEBUG_LOG after  getStorageAccountByName blobServiceClient{}", credential.getAccountName());
        } catch (Exception e) {
            log.debug("DEBUG_LOG inside getBlobBatchClient inside catch msg : {}",e.getMessage());
        }
        log.debug("DEBUG_LOG inside getBlobBatchClient before return");
        return new BlobBatchClientBuilder(blobServiceClient).buildClient();

    }

Expected behavior
Calling the this line blobServiceClient = (new BlobServiceClientBuilder()).endpoint(endpoint).credential(credential).buildClient(); should return either data or null or error or exception

Screenshots
NA

Setup (please complete the following information):

  • OS: [e.g. iOS] :SUSE
  • IDE: [e.g. IntelliJ]
  • Library/Libraries: Azure SDK
  • Java version: [e.g. 8] java 17
  • App Server/Environment:Azure
  • Frameworks: [e.g. Spring Boot, Micronaut, Quarkus, etc] Spring Boot
  • Azure-storage-common: 12.17
  • Azure-storage-blob:12:30

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:

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

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

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.StorageStorage Service (Queues, Blobs, Files)customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions