Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
7711785
Disable Jetty by default. (#4964)
mitchdenny Aug 14, 2019
1b40f3a
Update package groups and add description in pom.xml for client libra…
srnagar Aug 14, 2019
7d24f9a
Event Hubs: Synchronous APIs Part 2 (#4970)
conniey Aug 14, 2019
6768fc9
Split the eventhubs client and data pipelines. (#4995)
mitchdenny Aug 14, 2019
58142d5
Add null check to fix spotbugs warning. (#4998)
conniey Aug 14, 2019
f173ae0
Seeing if we can speed up spotbugs (#4988)
JonathanGiles Aug 14, 2019
1ac4b2b
Enabling javadoc production for template. (#4963)
mitchdenny Aug 15, 2019
d44d8c3
Update link to Java Guidelines. (#4842)
Aug 15, 2019
ca83bd9
Fixes on Check on checkstyle (#5003)
mssfang Aug 15, 2019
99e76b4
Update Storage swagger (#4981)
tg-msft Aug 15, 2019
6eb9e89
Added spock test framework and tests for queue service (#4940)
sima-zhu Aug 15, 2019
2eec622
Fix directory path. (#5012)
mitchdenny Aug 16, 2019
56dc993
Renaming IterableResponse to IterableStream (#5002)
JonathanGiles Aug 16, 2019
faa0ef7
Add tracing context to storage blobs (#4752)
samvaity Aug 16, 2019
6f0f73f
Checkstyle - Javadoc - enforce formating for param, return and throw …
vhvb1989 Aug 16, 2019
0beab53
Fixes URL hosts with path segments (#4917)
jianghaolu Aug 16, 2019
f95da5a
Add staging profile id. (#5025)
mitchdenny Aug 16, 2019
5eab1e6
Adding Gauri Prassad to Storage Code Owner List (#5023)
alzimmermsft Aug 16, 2019
e688eb6
Feature/unified pipeline staging profiles (#5018)
mitchdenny Aug 16, 2019
8d0068d
Check if the first character in the passed SASToken string is a quest…
alzimmermsft Aug 16, 2019
41418b4
Make StorageException a POJO (#4924)
alzimmermsft Aug 16, 2019
bb70bee
Smoke test for Java (#4805)
JonathanCrd Aug 16, 2019
076e0f8
Fix URL construction for Storage (#5027)
jianghaolu Aug 17, 2019
84fa1c4
Use constant ServiceBus audience instead of letting the user provide …
bainian12345 Aug 17, 2019
146e3a8
Major version bump for service bus. (#5029)
mitchdenny Aug 17, 2019
b111ad3
CosmosDB: package 2015-04-08 update. (#5033)
yaohaizh Aug 19, 2019
32b7f60
Okhttp bug fix (#4944)
g2vinay Aug 19, 2019
619c70a
Adding rule to expect a text description for deprecated javadoc tags …
vhvb1989 Aug 19, 2019
6f80595
CheckStyle: regex for suppression and a few fiexes for generated chec…
mssfang Aug 19, 2019
37a35dd
remove cosmosdb/data-plane (#5037)
christopheranderson Aug 19, 2019
3aa5160
Adding rule for enforcing final field usage - DoNotMerge until all is…
vhvb1989 Aug 19, 2019
aceafd6
Update Storage Files swagger to 2019-02-02 (#5028)
tg-msft Aug 19, 2019
fe2039f
CosmosDb: Remove blocking calls from CFP (#4602)
milismsft Aug 20, 2019
608b30f
Cosmos Direct TCP port from azure-cosmosdb v2.6.1 (#5042)
Aug 20, 2019
9884b8a
Custom CheckStyle Rule #9: Thrown exception use ClientLogger (#4566)
mssfang Aug 20, 2019
926de5b
Fix Install Linting Issues (#5057)
alzimmermsft Aug 20, 2019
84dfd55
Add tracing context to storage queue (#4934)
samvaity Aug 20, 2019
4d892df
Storage file service spock tests (#4991)
sima-zhu Aug 20, 2019
8935711
Fix the wrong imports (#5069)
sima-zhu Aug 21, 2019
1713919
Added fake connection string for playback tests. (#5072)
sima-zhu Aug 21, 2019
c0386ae
Bump version. (#5077)
mitchdenny Aug 21, 2019
5583eb0
Remove the Netty dependency from azure-core (#4572)
JonathanGiles Aug 22, 2019
a89afa0
Fix tests (#5080)
sima-zhu Aug 22, 2019
88f4a6f
Remove parent/pom.xml for Event Hubs Track 1 (#5090)
conniey Aug 22, 2019
64efc1b
Add tracing context in Storage Files (#4888)
samvaity Aug 22, 2019
6610afa
Add Impressions tracking link to READMEs (#5035)
g2vinay Aug 22, 2019
1234a3a
Tune management build triggering (#5078)
mitchdenny Aug 22, 2019
025647a
JavaDoc and parameter validation improvements (#5098)
conniey Aug 23, 2019
8bd0f47
Storage: Updated Listing Operation Return Types (#4803)
jaschrep-msft Aug 23, 2019
437afae
Playback and Record for Azure Storage Blob (#4971)
alzimmermsft Aug 23, 2019
e77284a
Update Swagger for Blobs and Files (#5094)
alzimmermsft Aug 23, 2019
ebbfe5a
getHandles to listHandles API changes. (#5055)
sima-zhu Aug 24, 2019
26cbf5a
Network: update package 2019_06_01. (#5095)
yaohaizh Aug 24, 2019
b1f7af5
Setup unified pipelines for sdk/authorization. (#4828)
mitchdenny Aug 26, 2019
c5730d1
Setup sdk/loganalytics for unified pipelines. (#4832)
mitchdenny Aug 26, 2019
416710a
Setup event grid for unified pipelines. (#4831)
mitchdenny Aug 26, 2019
9cee15b
Setup mediaservices for unified pipelines. (#4833)
mitchdenny Aug 26, 2019
5f61d18
Setup AI for unified pipelines. (#4827)
mitchdenny Aug 26, 2019
27cfb8e
Setup unified pipelines for sdk/cognitiveservices (#4830)
mitchdenny Aug 26, 2019
10f0d47
Add azure batch code owners (#4573)
bgklein Aug 26, 2019
3911729
Add Storage to SpotBugs Aggregate Report (#5089)
alzimmermsft Aug 26, 2019
e0f3c5a
Using ISO8601 instead of RFC1123 in response type (#5109)
alzimmermsft Aug 26, 2019
6d300f3
Added clearRange and remove the FileRangeWriteType (#5060)
sima-zhu Aug 26, 2019
9371a88
Fixed logger setup bug in Storage SDK test setup (#5112)
jaschrep-msft Aug 26, 2019
6b14ac0
add more eng entries to CODEOWNERS (#5110)
danieljurek Aug 26, 2019
23aa967
Added core-http-netty to set of artificts to publish. (#5107)
mitchdenny Aug 26, 2019
08fab71
Basic plumbing for pipeline caching. (#5086)
mitchdenny Aug 26, 2019
c1d5a52
Whitespace change to test pipeline config.
mitchdenny Aug 26, 2019
109b1a8
Add suppression for null check. (#5118)
mitchdenny Aug 27, 2019
b6a884d
Add netty library to set of docs generated so it can publish/sign. (#…
mitchdenny Aug 27, 2019
bb2c2bb
Enabling Cosmos for Unified Pipelines (#5102)
mitchdenny Aug 27, 2019
ba8dbc1
Removed azure-core-http-netty from the published artifact list. (#5121)
mitchdenny Aug 27, 2019
f6f89c8
CheckStyleRule-Javadoc-Codesnippet Batch#3, No.7 and No.8 (#4920)
mssfang Aug 27, 2019
e4ebe48
Improve Track 1 Event Hubs RBAC tests (#5133)
JamesBirdsall Aug 27, 2019
ed9d8b6
CustomCheckStyleRules: Good Logging Practice (#3359)
mssfang Aug 27, 2019
6ccb9c6
Remove Storage swagger files and reference azure-rest-api-specs (#5116)
tg-msft Aug 28, 2019
9ccb976
Custom CheckStyle rules: Fluent Method Name Check (#3366)
mssfang Aug 28, 2019
3eda854
Remove suppression and fix error. (#5143)
conniey Aug 28, 2019
d2df860
pom updates (#5151)
g2vinay Aug 28, 2019
b7bf03b
use expected artifact names (#5148)
danieljurek Aug 28, 2019
66fd3cd
Custom CheckStyle: Batch 2, Rule #5 and #10; Batch 3, Rule #1 and #6 …
mssfang Aug 28, 2019
d856608
Adding java automatic module names to all track two client libraries …
JonathanGiles Aug 29, 2019
2da7e73
Generated from 5e1bb35d5c3314d8f4fead76c3d69a2522be026b
Aug 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Custom CheckStyle Rule #9: Thrown exception use ClientLogger (Azure#4566
)

(1) the implementation for Rule 9: Thrown exception use ClientLogger
To throw an exception, Must throw it through a 'logger.logExceptionAsError', rather than by directly calling 'throw exception'.
Skip check if throw exception from
Static method
Static class
Constructor
(2) code fixes based on the new rule: ThrowFromClientLoggerCheck.java
(3) a minor fixes for NoImplInPublicAPI.java checker:
Removes track 2 and implementation check in Java Code instead of suppressing the rule
(4) fixes for ServiceClientBuilder checker for Storage service.
  • Loading branch information
mssfang authored Aug 20, 2019
commit 9884b8addb7edf61c17cb93ce91c136afe318deb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public class NoImplInPublicAPI extends AbstractCheck {
private static final String PARAM_TYPE_ERROR = "\"%s\" class is in an implementation package, and it should not be used as a parameter type in public API. Alternatively, it can be removed from the implementation package and made public API, after appropriate API review.";
private static final String RETURN_TYPE_ERROR = "\"%s\" class is in an implementation package, and it should not be a return type from public API. Alternatively, it can be removed from the implementation package and made public API.";

private static boolean isTrackTwo;
private static boolean isImplPackage;
private Set<String> implementationClassSet = new HashSet<>();

@Override
Expand All @@ -43,28 +41,11 @@ public int[] getRequiredTokens() {

@Override
public void beginTree(DetailAST root) {
this.isImplPackage = false;
this.isTrackTwo = false;
this.implementationClassSet.clear();
}

@Override
public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.PACKAGE_DEF) {
String packageName = FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
this.isTrackTwo = packageName.startsWith(COM_AZURE);
this.isImplPackage = packageName.contains(DOT_IMPLEMENTATION);
return;
} else {
if (this.isTrackTwo) {
if (this.isImplPackage) {
return;
}
} else {
return;
}
}

switch (ast.getType()) {
case TokenTypes.IMPORT:
String importClassPath = FullIdent.createFullIdentBelow(ast).getText();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.tools.checkstyle.checks;

import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.FullIdent;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;

import java.util.ArrayDeque;
import java.util.Deque;

/**
* To throw an exception, Must throw it through a 'logger.logExceptionAsError', rather than by directly calling 'throw exception'.
*
* Skip check if throwing exception from
* <ol>
* <li>Static method</li>
* <li>Static class</li>
* <li>Constructor</li>
* </ol>
*/
public class ThrowFromClientLoggerCheck extends AbstractCheck {
private static final String LOGGER_LOG_EXCEPTION_AS_ERROR = "logger.logExceptionAsError";
private static final String LOGGER_LOG_EXCEPTION_AS_WARNING = "logger.logExceptionAsWarning";
private static final String THROW_LOGGER_EXCEPTION_MESSAGE = "Directly throwing an exception is disallowed. Must "
+ "throw through ''ClientLogger'' API, either of ''%s'' or ''%s'' where ''logger'' is type of ClientLogger from Azure Core package.";

// A container stores the static status of class, skip this ThrowFromClientLoggerCheck if the class is static
private final Deque<Boolean> classStaticDeque = new ArrayDeque<>();
// A container stores the static status of method, skip this ThrowFromClientLoggerCheck if the method is static
private final Deque<Boolean> methodStaticDeque = new ArrayDeque<>();
// The variable is used to indicate if current node is still inside of constructor.
private boolean isInConstructor = false;

@Override
public int[] getDefaultTokens() {
return getRequiredTokens();
}

@Override
public int[] getAcceptableTokens() {
return getRequiredTokens();
}

@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.LITERAL_THROW,
TokenTypes.METHOD_DEF
};
}

@Override
public void leaveToken(DetailAST token) {
switch (token.getType()) {
case TokenTypes.CLASS_DEF:
classStaticDeque.pop();
break;
case TokenTypes.CTOR_DEF:
isInConstructor = false;
break;
case TokenTypes.METHOD_DEF:
methodStaticDeque.pop();
break;
default:
// Checkstyle complains if there's no default block in switch
break;
}
}

@Override
public void visitToken(DetailAST token) {
switch (token.getType()) {
case TokenTypes.CLASS_DEF:
DetailAST modifiersToken = token.findFirstToken(TokenTypes.MODIFIERS);
classStaticDeque.addLast(modifiersToken.branchContains(TokenTypes.LITERAL_STATIC));
break;
case TokenTypes.CTOR_DEF:
isInConstructor = true;
break;
case TokenTypes.METHOD_DEF:
DetailAST methodModifiersToken = token.findFirstToken(TokenTypes.MODIFIERS);
methodStaticDeque.addLast(methodModifiersToken.branchContains(TokenTypes.LITERAL_STATIC));
break;
case TokenTypes.LITERAL_THROW:
// Skip check if the throw exception from static class, constructor or static method
if (classStaticDeque.isEmpty() || classStaticDeque.peekLast() || isInConstructor
|| methodStaticDeque.isEmpty() || methodStaticDeque.peekLast()) {
return;
}
DetailAST methodCallToken = token.findFirstToken(TokenTypes.EXPR).findFirstToken(TokenTypes.METHOD_CALL);
if (methodCallToken == null) {
log(token, String.format(THROW_LOGGER_EXCEPTION_MESSAGE, LOGGER_LOG_EXCEPTION_AS_ERROR, LOGGER_LOG_EXCEPTION_AS_WARNING));
return;
}

String methodCallName = FullIdent.createFullIdent(methodCallToken.findFirstToken(TokenTypes.DOT)).getText();
if (!LOGGER_LOG_EXCEPTION_AS_ERROR.equals(methodCallName) && !LOGGER_LOG_EXCEPTION_AS_WARNING.equals(methodCallName)) {
log(token, String.format(THROW_LOGGER_EXCEPTION_MESSAGE, LOGGER_LOG_EXCEPTION_AS_ERROR, LOGGER_LOG_EXCEPTION_AS_WARNING));
}
break;
default:
// Checkstyle complains if there's no default block in switch
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,20 @@

<!-- Remove this after fixing: https://github.com/Azure/azure-sdk-for-java/issues/5021 -->
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files=".*\BlobOutputStream.java"/>


<!-- Don't apply custom Checkstyle rules to files under test package -->
<suppress checks="com\.azure\.tools\.checkstyle\.checks\.(ExternalDependencyExposedCheck|NoImplInPublicAPI|ServiceClientInstantiationCheck
|ServiceClientBuilderCheck|ServiceInterfaceCheck|HttpPipelinePolicyCheck|JavaDocFormatting|JavadocThrowsChecks
|EnforceFinalFieldsCheck)" files=".*[/\\]src[/\\]test[/\\]java[/\\].*\.java"/>
|ThrowFromClientLoggerCheck|EnforceFinalFieldsCheck)" files=".*[/\\]src[/\\]test[/\\]java[/\\].*\.java"/>

<!-- Custom checkstyle rules that don't apply to files under implementation package -->
<suppress checks="com\.azure\.tools\.checkstyle\.checks\.(ExternalDependencyExposedCheck|ServiceClientInstantiationCheck
|ServiceClientBuilderCheck|ServiceInterfaceCheck|JavaDocFormatting|JavadocThrowsChecks|EnforceFinalFieldsCheck)"
<!-- Don't apply custom Checkstyle rules to files under implementation package -->
<suppress checks="com\.azure\.tools\.checkstyle\.checks\.(ExternalDependencyExposedCheck|NoImplInPublicAPI|ServiceClientInstantiationCheck
|ServiceClientBuilderCheck|ServiceInterfaceCheck|JavaDocFormatting|JavadocThrowsChecks|EnforceFinalFieldsCheck|ThrowFromClientLoggerCheck)"
files=".*[/\\]implementation[/\\].*\.java"/>

<!-- Custom checkstyle rules that don't apply to files under samples package -->
<!-- Don't apply custom Checkstyle rules to files under samples package -->
<suppress checks="com\.azure\.tools\.checkstyle\.checks\.(ExternalDependencyExposedCheck|HttpPipelinePolicyCheck|JavadocPackage
|EnforceFinalFieldsCheck)" files=".*[/\\]samples[/\\].*\.java"/>
|EnforceFinalFieldsCheck|ThrowFromClientLoggerCheck)" files=".*[/\\]samples[/\\].*\.java"/>

<!-- Don't apply custom Checkstyle rules to files under checkstyle package. -->
<suppress checks="com\.azure\.tools\.checkstyle\.checks\..+" files=".*[/\\]tools[/\\]checkstyle[/\\].*"/>
Expand All @@ -118,4 +119,14 @@

<!-- Suppress warnings for Event Processor until the usage of "Client" is discussed and resolved: https://github.com/Azure/azure-sdk/issues/321 -->
<suppress checks="com.azure.tools.checkstyle.checks.ServiceClientBuilderCheck" files=".*EventHubClientBuilder.java"/>

<!-- Any code in any package, it should never be a 'throw' keyword in the client library codebase except for in the client logger -->
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck" files=".*[/\\]com[/\\]azure[/\\]core[/\\]util[/\\]logging[/\\]*"/>

<!-- Suppress IO exception for now, which need code owner's attention -->
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck" files="com.azure.core.implementation.util.ClientLoggerJavaDocCodeSnippets.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck" files="com.azure.storage.blob.BlobInputStream.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck" files="com.azure.storage.blob.BlobOutputStream.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck" files="com.azure.storage.blob.BlockBlobClient.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck" files="com.azure.storage.blob.PageBlobAsyncClient.java"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ page at http://checkstyle.sourceforge.net/config.html -->

<!--CUSTOM CHECKS-->
<!-- Must use 'logger.logAndThrow' but not directly calling 'throw exception' -->
<!-- <module name="com.azure.tools.checkstyle.checks.ThrownClientLoggerCheck"/>-->
<module name="com.azure.tools.checkstyle.checks.ThrowFromClientLoggerCheck"/>

<!--CUSTOM CHECKS-->
<!-- Any class that implements the HttpPipelinePolicy interface should:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
package com.azure.data.appconfiguration.credentials;

import com.azure.core.util.logging.ClientLogger;
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
import com.azure.data.appconfiguration.policy.ConfigurationCredentialsPolicy;
import com.azure.core.implementation.util.ImplUtils;
Expand Down Expand Up @@ -37,6 +38,8 @@
* @see ConfigurationClientBuilder
*/
public class ConfigurationClientCredentials {
private final ClientLogger logger = new ClientLogger(ConfigurationClientCredentials.class);

private static final String HOST_HEADER = "Host";
private static final String DATE_HEADER = "Date";
private static final String CONTENT_HASH_HEADER = "x-ms-content-sha256";
Expand Down Expand Up @@ -81,7 +84,7 @@ public Mono<Map<String, String>> getAuthorizationHeadersAsync(URL url, String ht
try {
return MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw Exceptions.propagate(e);
throw logger.logExceptionAsError(Exceptions.propagate(e));
}
}, (messageDigest, byteBuffer) -> {
if (messageDigest != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.core.management;

import com.azure.core.exception.HttpResponseException;
import com.azure.core.util.logging.ClientLogger;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -21,6 +22,8 @@
* @param <E> the element type.
*/
public abstract class PagedList<E> implements List<E> {
private final ClientLogger logger = new ClientLogger(PagedList.class);

/** The actual items in the list. */
private final List<E> items;
/** Stores the latest page fetched. */
Expand Down Expand Up @@ -67,7 +70,7 @@ private void cachePage(String nextPageLink) {
}
}
} catch (IOException ex) {
throw new RuntimeException(ex);
throw logger.logExceptionAsError(new RuntimeException(ex));
}
}

Expand Down Expand Up @@ -137,6 +140,8 @@ protected void setCurrentPage(Page<E> currentPage) {
* The implementation of {@link ListIterator} for PagedList.
*/
private class ListItr implements ListIterator<E> {
private final ClientLogger logger = new ClientLogger(ListItr.class);

/**
* index of next element to return.
*/
Expand Down Expand Up @@ -164,7 +169,7 @@ public boolean hasNext() {
public E next() {
if (this.nextIndex >= items.size()) {
if (!hasNextPage()) {
throw new NoSuchElementException();
throw logger.logExceptionAsError(new NoSuchElementException());
} else {
loadNextPage();
}
Expand All @@ -179,22 +184,22 @@ public E next() {
} catch (IndexOutOfBoundsException ex) {
// The nextIndex got invalid means a different instance of iterator
// removed item from this index.
throw new ConcurrentModificationException();
throw logger.logExceptionAsError(new ConcurrentModificationException(ex));
}
}
}

@Override
public void remove() {
if (this.lastRetIndex < 0) {
throw new IllegalStateException();
throw logger.logExceptionAsError(new IllegalStateException());
} else {
try {
items.remove(this.lastRetIndex);
this.nextIndex = this.lastRetIndex;
this.lastRetIndex = -1;
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
throw logger.logExceptionAsError(new ConcurrentModificationException(ex));
}
}
}
Expand All @@ -208,16 +213,16 @@ public boolean hasPrevious() {
public E previous() {
int i = this.nextIndex - 1;
if (i < 0) {
throw new NoSuchElementException();
throw logger.logExceptionAsError(new NoSuchElementException());
} else if (i >= items.size()) {
throw new ConcurrentModificationException();
throw logger.logExceptionAsError(new ConcurrentModificationException());
} else {
try {
this.nextIndex = i;
this.lastRetIndex = i;
return items.get(this.lastRetIndex);
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
throw logger.logExceptionAsError(new ConcurrentModificationException(ex));
}
}
}
Expand All @@ -235,12 +240,12 @@ public int previousIndex() {
@Override
public void set(E e) {
if (this.lastRetIndex < 0) {
throw new IllegalStateException();
throw logger.logExceptionAsError(new IllegalStateException());
} else {
try {
items.set(this.lastRetIndex, e);
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
throw logger.logExceptionAsError(new ConcurrentModificationException(ex));
}
}
}
Expand All @@ -252,7 +257,7 @@ public void add(E e) {
this.nextIndex = this.nextIndex + 1;
this.lastRetIndex = -1;
} catch (IndexOutOfBoundsException ex) {
throw new ConcurrentModificationException();
throw logger.logExceptionAsError(new ConcurrentModificationException(ex));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.azure.core.management.AsyncOperationResource;
import com.azure.core.management.CloudException;
import com.azure.core.management.OperationState;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Mono;

import java.io.IOException;
Expand All @@ -23,6 +24,8 @@
* running operation.
*/
public final class AzureAsyncOperationPollStrategy extends PollStrategy {
private final ClientLogger logger = new ClientLogger(AzureAsyncOperationPollStrategy.class);

private AzureAsyncOperationPollStrategyData data;

/**
Expand Down Expand Up @@ -100,7 +103,7 @@ public HttpRequest createPollRequest() {
pollUrl = data.originalResourceUrl;
}
} else {
throw new IllegalStateException("Polling is completed and did not succeed. Cannot create a polling request.");
throw logger.logExceptionAsError(new IllegalStateException("Polling is completed and did not succeed. Cannot create a polling request."));
}

return new HttpRequest(HttpMethod.GET, pollUrl);
Expand All @@ -122,7 +125,7 @@ public Mono<HttpResponse> updateFromAsync(HttpResponse httpPollResponse) {
} catch (IOException ignored) { }
//
if (operationResource == null || operationResource.status() == null) {
throw new CloudException("The polling response does not contain a valid body", bufferedHttpPollResponse, null);
throw logger.logExceptionAsError(new CloudException("The polling response does not contain a valid body", bufferedHttpPollResponse, null));
} else {
final String status = operationResource.status();
setStatus(status);
Expand All @@ -133,7 +136,7 @@ public Mono<HttpResponse> updateFromAsync(HttpResponse httpPollResponse) {
clearDelayInMilliseconds();

if (!data.pollingSucceeded) {
throw new CloudException("Async operation failed with provisioning state: " + status, bufferedHttpPollResponse);
throw logger.logExceptionAsError(new CloudException("Async operation failed with provisioning state: " + status, bufferedHttpPollResponse));
}

if (operationResource.id() != null) {
Expand Down
Loading