diff --git a/modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java b/modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java index f2bba1a79a57d..80bd788da9a9f 100644 --- a/modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java +++ b/modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java @@ -10,10 +10,12 @@ import fixture.azure.AzureHttpFixture; +import com.azure.core.exception.HttpResponseException; import com.azure.storage.blob.BlobContainerClient; import com.azure.storage.blob.BlobServiceClient; import com.azure.storage.blob.models.BlobStorageException; +import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionRunnable; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -188,8 +190,8 @@ public void testMultiBlockUpload() throws Exception { public void testReadFromPositionLargerThanBlobLength() { testReadFromPositionLargerThanBlobLength( - e -> asInstanceOf(BlobStorageException.class, e.getCause()).getStatusCode() == RestStatus.REQUESTED_RANGE_NOT_SATISFIED - .getStatus() + e -> asInstanceOf(BlobStorageException.class, ExceptionsHelper.unwrap(e, HttpResponseException.class)) + .getStatusCode() == RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus() ); } } diff --git a/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobContainer.java b/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobContainer.java index d271c8d1e99a1..eb643b3c1460d 100644 --- a/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobContainer.java +++ b/modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobContainer.java @@ -8,11 +8,11 @@ package org.elasticsearch.repositories.azure; -import com.azure.storage.blob.models.BlobStorageException; +import com.azure.core.exception.HttpResponseException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.util.Throwables; +import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Strings; import org.elasticsearch.common.blobstore.BlobContainer; @@ -69,13 +69,13 @@ private InputStream openInputStream(OperationPurpose purpose, String blobName, l try { return blobStore.getInputStream(blobKey, position, length); } catch (Exception e) { - Throwable rootCause = Throwables.getRootCause(e); - if (rootCause instanceof BlobStorageException blobStorageException) { - if (blobStorageException.getStatusCode() == RestStatus.NOT_FOUND.getStatus()) { + if (ExceptionsHelper.unwrap(e, HttpResponseException.class) instanceof HttpResponseException httpResponseException) { + final var httpStatusCode = httpResponseException.getResponse().getStatusCode(); + if (httpStatusCode == RestStatus.NOT_FOUND.getStatus()) { throw new NoSuchFileException("Blob [" + blobKey + "] not found"); } - if (blobStorageException.getStatusCode() == RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus()) { - throw new RequestedRangeNotSatisfiedException(blobKey, position, length == null ? -1 : length, blobStorageException); + if (httpStatusCode == RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus()) { + throw new RequestedRangeNotSatisfiedException(blobKey, position, length == null ? -1 : length, e); } } throw new IOException("Unable to get input stream for blob [" + blobKey + "]", e); diff --git a/muted-tests.yml b/muted-tests.yml index 96fc68cdc3b8a..26be6e9389368 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -97,9 +97,6 @@ tests: - class: org.elasticsearch.xpack.security.authc.oidc.OpenIdConnectAuthIT method: testAuthenticateWithImplicitFlow issue: https://github.com/elastic/elasticsearch/issues/111191 -- class: org.elasticsearch.repositories.azure.AzureBlobContainerRetriesTests - method: testReadNonexistentBlobThrowsNoSuchFileException - issue: https://github.com/elastic/elasticsearch/issues/111233 - class: org.elasticsearch.action.admin.indices.create.SplitIndexIT method: testSplitIndexPrimaryTerm issue: https://github.com/elastic/elasticsearch/issues/111282