Skip to content

Commit

Permalink
Fix checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Siegel committed Sep 7, 2020
1 parent 7a9c189 commit 19acd89
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.data.tables;

import com.azure.core.exception.AzureException;
Expand All @@ -19,7 +21,10 @@ protected CosmosThrottled(T client, boolean isPlaybackMode) {
public abstract boolean isCosmos();

public void runVoid(Consumer<T> action) {
run(c -> { action.accept(c); return null; });
run(c -> {
action.accept(c);
return null;
});
}

public T getClient() {
Expand All @@ -33,26 +38,20 @@ public <TResult> TResult run(Function<T, TResult> action) {

int retryCount = 0;
int delay = 1500;
while (true)
{
try
{
while (true) {
try {
return action.apply(client);
}
catch (TableServiceErrorException e)
{
} catch (TableServiceErrorException e) {
if (e.getResponse().getStatusCode() != 429) {
throw e;
}

if (++retryCount > 10)
{
if (++retryCount > 10) {
throw e;
}

// Disable retry throttling in Playback mode.
if (!isPlaybackMode)
{
if (!isPlaybackMode) {
try {
Thread.sleep(delay);
} catch (InterruptedException interruptedException) {
Expand All @@ -65,7 +64,7 @@ public <TResult> TResult run(Function<T, TResult> action) {
}

public static CosmosThrottled<TableServiceAsyncClient> get(TableServiceAsyncClient client, boolean isPlaybackMode) {
return new CosmosThrottled<>(client, isPlaybackMode) {
return new CosmosThrottled<TableServiceAsyncClient>(client, isPlaybackMode) {
@Override
public boolean isCosmos() {
return client.getServiceUrl().contains("cosmos.azure.com");
Expand All @@ -74,7 +73,7 @@ public boolean isCosmos() {
}

public static CosmosThrottled<TableServiceClient> get(TableServiceClient client, boolean isPlaybackMode) {
return new CosmosThrottled<>(client, isPlaybackMode) {
return new CosmosThrottled<TableServiceClient>(client, isPlaybackMode) {
@Override
public boolean isCosmos() {
return client.getServiceUrl().contains("cosmos.azure.com");
Expand All @@ -83,7 +82,7 @@ public boolean isCosmos() {
}

public static CosmosThrottled<TableAsyncClient> get(TableAsyncClient client, boolean isPlaybackMode) {
return new CosmosThrottled<>(client, isPlaybackMode) {
return new CosmosThrottled<TableAsyncClient>(client, isPlaybackMode) {
@Override
public boolean isCosmos() {
return client.getTableUrl().contains("cosmos.azure.com");
Expand All @@ -92,7 +91,7 @@ public boolean isCosmos() {
}

public static CosmosThrottled<TableClient> get(TableClient client, boolean isPlaybackMode) {
return new CosmosThrottled<>(client, isPlaybackMode) {
return new CosmosThrottled<TableClient>(client, isPlaybackMode) {
@Override
public boolean isCosmos() {
return client.getTableUrl().contains("cosmos.azure.com");
Expand All @@ -101,7 +100,7 @@ public boolean isCosmos() {
}

public static CosmosThrottled<AzureTableImpl> get(AzureTableImpl client, boolean isPlaybackMode) {
return new CosmosThrottled<>(client, isPlaybackMode) {
return new CosmosThrottled<AzureTableImpl>(client, isPlaybackMode) {
@Override
public boolean isCosmos() {
return client.getUrl().contains("cosmos.azure.com");
Expand Down

0 comments on commit 19acd89

Please sign in to comment.