diff --git a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java
index ed7a0cd575017..2fc3c3338b1b1 100644
--- a/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java
+++ b/sdk/storage/azure-storage-file/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java
@@ -118,13 +118,11 @@ public String computeHmac256(final String stringToSign) {
byte[] utf8Bytes = stringToSign.getBytes(StandardCharsets.UTF_8);
return Base64.getEncoder().encodeToString(hmacSha256.doFinal(utf8Bytes));
} catch (final NoSuchAlgorithmException e) {
- String errorMsg = "There is no such algorithm. Error Details: " + e.getMessage();
- logger.warning(errorMsg);
- throw new RuntimeException(errorMsg);
+ logger.logAndThrow(new RuntimeException("There is no such algorithm. Error Details: " + e.getMessage()));
+ return null;
} catch (InvalidKeyException e) {
- String errorMsg = "Please double check the account key. Error details: " + e.getMessage();
- logger.warning(errorMsg);
- throw new RuntimeException(errorMsg);
+ logger.logAndThrow(new RuntimeException("Please double check the account key. Error details: " + e.getMessage()));
+ return null;
}
}
@@ -236,8 +234,8 @@ private String computeHMACSHA256(String stringToSign) {
String signature = Base64.getEncoder().encodeToString(hmacSha256.doFinal(utf8Bytes));
return String.format(AUTHORIZATION_HEADER_FORMAT, accountName, signature);
} catch (NoSuchAlgorithmException | InvalidKeyException ex) {
- logger.warning(ex.getMessage());
- throw new Error(ex);
+ logger.logAndThrow(new RuntimeException(ex.getMessage()));
+ return null;
}
}
}
diff --git a/sdk/storage/azure-storage-queue/pom.xml b/sdk/storage/azure-storage-queue/pom.xml
index 669a3b2458bd5..04e3b176d650b 100644
--- a/sdk/storage/azure-storage-queue/pom.xml
+++ b/sdk/storage/azure-storage-queue/pom.xml
@@ -37,10 +37,6 @@
azure-core
1.0.0-preview.3
-
- org.slf4j
- slf4j-api
-
com.azure
@@ -59,20 +55,10 @@
junit
test
-
- org.slf4j
- slf4j-simple
- test
-
io.projectreactor
reactor-test
test
-
- com.microsoft.azure
- adal4j
- test
-
diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java
index a9892459cda6c..ebd51b993f79a 100644
--- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java
+++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/common/credentials/SharedKeyCredential.java
@@ -27,7 +27,7 @@
* SharedKey credential policy that is put into a header to authorize requests.
*/
public final class SharedKeyCredential {
- private static final ClientLogger LOGGER = new ClientLogger(SharedKeyCredential.class);
+ private final ClientLogger logger = new ClientLogger(SharedKeyCredential.class);
private static final String AUTHORIZATION_HEADER_FORMAT = "SharedKey %s:%s";
// Pieces of the connection string that are needed.
@@ -101,8 +101,10 @@ public String generateAuthorizationHeader(URL requestURL, String httpMethod, Map
* @param stringToSign The UTF-8-encoded string to sign.
* @return A {@code String} that contains the HMAC-SHA256-encoded signature.
* @throws RuntimeException for one of the following cases:
- * - If the HMAC-SHA256 signature for {@code sharedKeyCredentials} fails to generate.
- * - If the an invalid key has been given to the client.
+ *
+ * - If the HMAC-SHA256 signature for {@code sharedKeyCredentials} fails to generate.
+ * - If the an invalid key has been given to the client.
+ *
*/
public String computeHmac256(final String stringToSign) {
try {
@@ -116,11 +118,11 @@ public String computeHmac256(final String stringToSign) {
byte[] utf8Bytes = stringToSign.getBytes(StandardCharsets.UTF_8);
return Base64.getEncoder().encodeToString(hmacSha256.doFinal(utf8Bytes));
} catch (final NoSuchAlgorithmException e) {
- LOGGER.error(e.getMessage());
- throw new RuntimeException(e);
+ logger.logAndThrow(new RuntimeException(e));
+ return null;
} catch (InvalidKeyException e) {
- LOGGER.error("Please double check the account key. Error details: " + e.getMessage());
- throw new RuntimeException("Please double check the account key. Error details: " + e.getMessage());
+ logger.logAndThrow(new RuntimeException("Please double check the account key. Error details: " + e.getMessage()));
+ return null;
}
}
@@ -232,8 +234,8 @@ private String computeHMACSHA256(String stringToSign) {
String signature = Base64.getEncoder().encodeToString(hmacSha256.doFinal(utf8Bytes));
return String.format(AUTHORIZATION_HEADER_FORMAT, accountName, signature);
} catch (NoSuchAlgorithmException | InvalidKeyException ex) {
- LOGGER.error(ex.getMessage());
- throw new Error(ex);
+ logger.logAndThrow(new RuntimeException(ex.getMessage()));
+ return null;
}
}
}
diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java
index 23bdec3f5d48f..736d60668dc44 100644
--- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java
+++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/common/policy/RequestRetryOptions.java
@@ -65,10 +65,10 @@ public RequestRetryOptions() {
*
* For more samples, please see the samples file
* @throws IllegalArgumentException If one of the following case exists:
- *
- * - There is only one null value for retryDelay and maxRetryDelay.
- * - Unrecognized retry policy type.
- *
+ *
+ * - There is only one null value for retryDelay and maxRetryDelay.
+ * - Unrecognized retry policy type.
+ *
*/
public RequestRetryOptions(RetryPolicyType retryPolicyType, Integer maxTries, Integer tryTimeout,
Long retryDelayInMs, Long maxRetryDelayInMs, String secondaryHost) {
diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java
index 659d128dc243b..54987d795116b 100644
--- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java
+++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueAsyncClient.java
@@ -50,7 +50,7 @@
* @see SASTokenCredential
*/
public final class QueueAsyncClient {
- private static final ClientLogger LOGGER = new ClientLogger(QueueAsyncClient.class);
+ private final ClientLogger logger = new ClientLogger(QueueAsyncClient.class);
private final AzureQueueStorageImpl client;
private final String queueName;
@@ -94,8 +94,8 @@ public URL getQueueUrl() {
try {
return new URL(client.getUrl());
} catch (MalformedURLException ex) {
- LOGGER.error("Queue URL is malformed");
- throw new RuntimeException("Queue URL is malformed");
+ logger.logAndThrow(new RuntimeException("Queue URL is malformed"));
+ return null;
}
}
diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java
index 8105465505d63..e30a336de1ce9 100644
--- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java
+++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueClientBuilder.java
@@ -73,7 +73,7 @@
* @see SharedKeyCredential
*/
public final class QueueClientBuilder {
- private static final ClientLogger LOGGER = new ClientLogger(QueueClientBuilder.class);
+ private final ClientLogger logger = new ClientLogger(QueueClientBuilder.class);
private static final String ACCOUNT_NAME = "accountname";
private final List policies;
@@ -138,8 +138,8 @@ public QueueAsyncClient buildAsyncClient() {
Objects.requireNonNull(queueName);
if (sasTokenCredential == null && sharedKeyCredential == null) {
- LOGGER.error("Credentials are required for authorization");
- throw new IllegalArgumentException("Credentials are required for authorization");
+ logger.logAndThrow(new IllegalArgumentException("Credentials are required for authorization"));
+ return null;
}
if (pipeline != null) {
@@ -205,8 +205,8 @@ public QueueClientBuilder endpoint(String endpoint) {
this.sasTokenCredential = credential;
}
} catch (MalformedURLException ex) {
- LOGGER.error("The Azure Storage Queue endpoint url is malformed. Endpoint: " + endpoint);
- throw new IllegalArgumentException("The Azure Storage Queue endpoint url is malformed. Endpoint: " + endpoint);
+ logger.logAndThrow(new IllegalArgumentException("The Azure Storage Queue endpoint url is malformed. Endpoint: " + endpoint));
+ return null;
}
return this;
@@ -273,10 +273,8 @@ private void getEndPointFromConnectionString(String connectionString) {
try {
this.endpoint = new URL(String.format("https://%s.queue.core.windows.net", accountName));
} catch (MalformedURLException e) {
- LOGGER.error("There is no valid account for the connection string. "
- + "Connection String: %s", connectionString);
- throw new IllegalArgumentException(String.format("There is no valid account for the connection string. "
- + "Connection String: %s", connectionString));
+ logger.logAndThrow(new IllegalArgumentException(String.format("There is no valid account for the connection string. "
+ + "Connection String: %s", connectionString)));
}
}
diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java
index 74a6e978a4f07..3491e25a4e490 100644
--- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java
+++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceAsyncClient.java
@@ -47,7 +47,7 @@
* @see SASTokenCredential
*/
public final class QueueServiceAsyncClient {
- private static final ClientLogger LOGGER = new ClientLogger(QueueServiceAsyncClient.class);
+ private final ClientLogger logger = new ClientLogger(QueueServiceAsyncClient.class);
private final AzureQueueStorageImpl client;
/**
@@ -71,8 +71,8 @@ public URL getQueueServiceUrl() {
try {
return new URL(client.getUrl());
} catch (MalformedURLException ex) {
- LOGGER.error("Queue Service URL is malformed");
- throw new RuntimeException("Storage account URL is malformed");
+ logger.logAndThrow(new RuntimeException("Storage account URL is malformed"));
+ return null;
}
}
diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java
index b7254eccc549e..81a06459e6876 100644
--- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java
+++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueServiceClientBuilder.java
@@ -70,7 +70,7 @@
* @see SharedKeyCredential
*/
public final class QueueServiceClientBuilder {
- private static final ClientLogger LOGGER = new ClientLogger(QueueServiceClientBuilder.class);
+ private final ClientLogger logger = new ClientLogger(QueueServiceClientBuilder.class);
private static final String ACCOUNT_NAME = "accountname";
private final List policies;
@@ -112,8 +112,8 @@ public QueueServiceAsyncClient buildAsyncClient() {
Objects.requireNonNull(endpoint);
if (sasTokenCredential == null && sharedKeyCredential == null) {
- LOGGER.error("Credentials are required for authorization");
- throw new IllegalArgumentException("Credentials are required for authorization");
+ logger.logAndThrow(new IllegalArgumentException("Credentials are required for authorization"));
+ return null;
}
if (pipeline != null) {
@@ -189,8 +189,8 @@ public QueueServiceClientBuilder endpoint(String endpoint) {
this.sasTokenCredential = credential;
}
} catch (MalformedURLException ex) {
- LOGGER.error("The Azure Storage Queue endpoint url is malformed.");
- throw new IllegalArgumentException("The Azure Storage Queue endpoint url is malformed.");
+ logger.logAndThrow(new IllegalArgumentException("The Azure Storage Queue endpoint url is malformed."));
+ return null;
}
return this;
@@ -245,10 +245,8 @@ private void getEndPointFromConnectionString(String connectionString) {
try {
this.endpoint = new URL(String.format("https://%s.queue.core.windows.net", accountName));
} catch (MalformedURLException e) {
- LOGGER.error("There is no valid account for the connection string. "
- + "Connection String: %s", connectionString);
- throw new IllegalArgumentException(String.format("There is no valid account for the connection string. "
- + "Connection String: %s", connectionString));
+ logger.logAndThrow(new IllegalArgumentException(String.format("There is no valid account for the connection string. "
+ + "Connection String: %s", connectionString)));
}
}