Skip to content

Commit

Permalink
Formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
clundin25 committed Sep 30, 2022
1 parent e0b5cfa commit 65547c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
45 changes: 24 additions & 21 deletions oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
Expand All @@ -63,7 +62,6 @@
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import javax.annotation.Nullable;

/** Base type for Credentials using OAuth2. */
Expand Down Expand Up @@ -581,31 +579,36 @@ void executeIfNew(Executor executor) {
class RefreshTask extends AbstractFuture<OAuthValue> implements Runnable {
private final ListenableFutureTask<OAuthValue> task;

RefreshTask(
ListenableFutureTask<OAuthValue> task) {
RefreshTask(ListenableFutureTask<OAuthValue> task) {
this.task = task;

// Update Credential state first
task.addListener(new Runnable() {
@Override
public void run() {
finishRefreshAsync(task);
}
}, MoreExecutors.directExecutor());
task.addListener(
new Runnable() {
@Override
public void run() {
finishRefreshAsync(task);
}
},
MoreExecutors.directExecutor());

// Then notify the world
Futures.addCallback(task, new FutureCallback<OAuthValue>() {
@Override
public void onSuccess(OAuthValue result) {
RefreshTask.this.set(result);
}

@Override
public void onFailure(Throwable t) {
RefreshTask.this.setException(t);
}
}, MoreExecutors.directExecutor());
Futures.addCallback(
task,
new FutureCallback<OAuthValue>() {
@Override
public void onSuccess(OAuthValue result) {
RefreshTask.this.set(result);
}

@Override
public void onFailure(Throwable t) {
RefreshTask.this.setException(t);
}
},
MoreExecutors.directExecutor());
}

public void run() {
task.run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@
import com.google.auth.TestUtils;
import com.google.auth.http.AuthHttpConstants;
import com.google.auth.oauth2.GoogleCredentialsTest.MockTokenServerTransportFactory;
import com.google.auth.oauth2.OAuth2Credentials.OAuthValue;
import com.google.auth.oauth2.OAuth2Credentials.RefreshTask;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ListenableFutureTask;
import com.google.common.util.concurrent.SettableFuture;
import java.io.IOException;
import java.net.URI;
Expand Down

0 comments on commit 65547c7

Please sign in to comment.