From 046a83a0e5f9eacd6a233f27c4127bf6f3624eb1 Mon Sep 17 00:00:00 2001 From: Gabriel Roldan Date: Wed, 7 Aug 2024 11:31:00 -0300 Subject: [PATCH] Fix Azure blobstore error instantiating AzureClient commit 72ce566b "Avoid infinite number of calls to listBlobs when doing prefix removals (e..g, gridset or layer removals)" changed the gwc `AzureClient` check for container existence from an attemp to create it to an attempt to get its properties before creating it. When the container doesn't exist, the blocking call throws `com.microsoft.azure.storage.blob.StorageException`, which contains the status code. Wrap that call in a try-catch block and get the status code from the exception. --- .../src/main/java/org/geowebcache/azure/AzureClient.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java index 2c5bae344..cd4475de1 100644 --- a/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java +++ b/geowebcache/azureblob/src/main/java/org/geowebcache/azure/AzureClient.java @@ -93,8 +93,13 @@ public AzureClient(AzureBlobStoreData configuration) throws StorageException { this.container = serviceURL.createContainerURL(containerName); // no way to see if the containerURL already exists, try to create and see if // we get a 409 CONFLICT + int status; + try { + status = this.container.getProperties().blockingGet().statusCode(); + } catch (com.microsoft.azure.storage.blob.StorageException se) { + status = se.statusCode(); + } try { - int status = this.container.getProperties().blockingGet().statusCode(); if (status == HttpStatus.NOT_FOUND.value()) { status = this.container.create(null, null, null).blockingGet().statusCode(); if (!HttpStatus.valueOf(status).is2xxSuccessful()