Skip to content

Commit 25e2e7f

Browse files
Sabrina Juarez GarciaBeta Bot
authored andcommitted
Cherry pick branch 'genexuslabs:feature/Update_AzureStorage_SDK' into beta
1 parent 22eb1e5 commit 25e2e7f

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

gxcloudstorage-azureblob-latest/src/main/java/com/genexus/db/driver/ExternalProviderAzureStorageLatest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,11 @@ private void initWithManagedIdentity() {
127127
private void initContainerClients() {
128128
// Create container clients and ensure containers exist
129129
publicContainerClient = blobServiceClient.getBlobContainerClient(publicContainerName);
130-
if (!publicContainerClient.exists()) {
131-
publicContainerClient = blobServiceClient.createBlobContainer(publicContainerName);
132-
publicContainerClient.setAccessPolicy(PublicAccessType.BLOB, null);
133-
}
134-
130+
publicContainerClient.createIfNotExists();
131+
publicContainerClient.setAccessPolicy(PublicAccessType.BLOB, null);
132+
135133
privateContainerClient = blobServiceClient.getBlobContainerClient(privateContainerName);
136-
if (!privateContainerClient.exists()) {
137-
privateContainerClient = blobServiceClient.createBlobContainer(privateContainerName);
138-
}
134+
privateContainerClient.createIfNotExists();
139135
}
140136

141137
public ExternalProviderAzureStorageLatest() throws Exception {
@@ -653,7 +649,7 @@ private String getExternalFileName(String externalFileName)
653649
{
654650
//Defensive code, as externalFileName may have a leading / and this causes a double / at blob uri
655651
//The latest Azure SDK is strict at uri format and encodes special characters
656-
if (externalFileName == "")
652+
if (externalFileName == null || externalFileName.isEmpty())
657653
return externalFileName;
658654
return externalFileName.startsWith("/") ? externalFileName.substring(1) : externalFileName;
659655
}
@@ -662,6 +658,7 @@ private void handleAndLogException(String message, Exception ex) {
662658
if (ex instanceof BlobStorageException) {
663659
logger.error("Azure Storage error: (Status: {}, Code: {})",
664660
((BlobStorageException) ex).getStatusCode(), ((BlobStorageException) ex).getErrorCode());
661+
throw new RuntimeException(ex.getMessage(), ex);
665662
} else if (ex instanceof ClientAuthenticationException) {
666663
logger.error("Authentication error: {}", ex.getMessage());
667664
} else if (ex instanceof HttpRequestException) {
@@ -673,6 +670,5 @@ private void handleAndLogException(String message, Exception ex) {
673670
} else {
674671
logger.error("Unexpected storage error", ex);
675672
}
676-
throw new RuntimeException(ex.getMessage(), ex);
677673
}
678674
}

0 commit comments

Comments
 (0)