Suppress warnings about deprecated CheckedFuture
CheckedFuture is deprecated in Guava 22. Remove imports of CheckedFuture and refer to it with explicit package name in the code, so we can suppress warnings where it's used rather than suppressing for the whole class. The latter would also suppress warnings if something else gets deprecated in future and cause us to miss it. Change-Id: I99d5021da205c9f1f4c6393ae3eb4c3e701efe20
This commit is contained in:
parent
365cdb76fe
commit
58087a18a0
@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.reviewdb.server;
|
||||
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@ -82,8 +81,10 @@ public class DisallowReadFromChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<Change, OrmException> getAsync(Change.Id key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<Change, OrmException> getAsync(
|
||||
Change.Id key) {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@ -113,8 +114,10 @@ public class DisallowReadFromChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<PatchSetApproval, OrmException> getAsync(PatchSetApproval.Key key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<PatchSetApproval, OrmException> getAsync(
|
||||
PatchSetApproval.Key key) {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@ -149,8 +152,10 @@ public class DisallowReadFromChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<ChangeMessage, OrmException> getAsync(ChangeMessage.Key key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<ChangeMessage, OrmException> getAsync(
|
||||
ChangeMessage.Key key) {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@ -190,8 +195,10 @@ public class DisallowReadFromChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<PatchSet, OrmException> getAsync(PatchSet.Id key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<PatchSet, OrmException> getAsync(
|
||||
PatchSet.Id key) {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@ -221,8 +228,10 @@ public class DisallowReadFromChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<PatchLineComment, OrmException> getAsync(PatchLineComment.Key key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<PatchLineComment, OrmException> getAsync(
|
||||
PatchLineComment.Key key) {
|
||||
throw new UnsupportedOperationException(MSG);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ package com.google.gerrit.reviewdb.server;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@ -190,8 +189,10 @@ public class ReviewDbWrapper implements ReviewDb {
|
||||
return delegate.toMap(c);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<Change, OrmException> getAsync(Change.Id key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<Change, OrmException> getAsync(
|
||||
Change.Id key) {
|
||||
return delegate.getAsync(key);
|
||||
}
|
||||
|
||||
@ -278,8 +279,10 @@ public class ReviewDbWrapper implements ReviewDb {
|
||||
return delegate.toMap(c);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<PatchSetApproval, OrmException> getAsync(PatchSetApproval.Key key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<PatchSetApproval, OrmException> getAsync(
|
||||
PatchSetApproval.Key key) {
|
||||
return delegate.getAsync(key);
|
||||
}
|
||||
|
||||
@ -384,8 +387,10 @@ public class ReviewDbWrapper implements ReviewDb {
|
||||
return delegate.toMap(c);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<ChangeMessage, OrmException> getAsync(ChangeMessage.Key key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<ChangeMessage, OrmException> getAsync(
|
||||
ChangeMessage.Key key) {
|
||||
return delegate.getAsync(key);
|
||||
}
|
||||
|
||||
@ -483,8 +488,10 @@ public class ReviewDbWrapper implements ReviewDb {
|
||||
return delegate.toMap(c);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<PatchSet, OrmException> getAsync(PatchSet.Id key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<PatchSet, OrmException> getAsync(
|
||||
PatchSet.Id key) {
|
||||
return delegate.getAsync(key);
|
||||
}
|
||||
|
||||
@ -577,8 +584,10 @@ public class ReviewDbWrapper implements ReviewDb {
|
||||
return delegate.toMap(c);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public CheckedFuture<PatchLineComment, OrmException> getAsync(PatchLineComment.Key key) {
|
||||
public com.google.common.util.concurrent.CheckedFuture<PatchLineComment, OrmException> getAsync(
|
||||
PatchLineComment.Key key) {
|
||||
return delegate.getAsync(key);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ import static com.google.gerrit.server.git.QueueProvider.QueueType.BATCH;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.util.concurrent.Atomics;
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
@ -73,7 +72,8 @@ public class ChangeIndexer {
|
||||
ChangeIndexer create(ListeningExecutorService executor, ChangeIndexCollection indexes);
|
||||
}
|
||||
|
||||
public static CheckedFuture<?, IOException> allAsList(
|
||||
@SuppressWarnings("deprecation")
|
||||
public static com.google.common.util.concurrent.CheckedFuture<?, IOException> allAsList(
|
||||
List<? extends ListenableFuture<?>> futures) {
|
||||
// allAsList propagates the first seen exception, wrapped in
|
||||
// ExecutionException, so we can reuse the same mapper as for a single
|
||||
@ -173,7 +173,9 @@ public class ChangeIndexer {
|
||||
* @param id change to index.
|
||||
* @return future for the indexing task.
|
||||
*/
|
||||
public CheckedFuture<?, IOException> indexAsync(Project.NameKey project, Change.Id id) {
|
||||
@SuppressWarnings("deprecation")
|
||||
public com.google.common.util.concurrent.CheckedFuture<?, IOException> indexAsync(
|
||||
Project.NameKey project, Change.Id id) {
|
||||
return submit(new IndexTask(project, id));
|
||||
}
|
||||
|
||||
@ -183,7 +185,8 @@ public class ChangeIndexer {
|
||||
* @param ids changes to index.
|
||||
* @return future for completing indexing of all changes.
|
||||
*/
|
||||
public CheckedFuture<?, IOException> indexAsync(
|
||||
@SuppressWarnings("deprecation")
|
||||
public com.google.common.util.concurrent.CheckedFuture<?, IOException> indexAsync(
|
||||
Project.NameKey project, Collection<Change.Id> ids) {
|
||||
List<ListenableFuture<?>> futures = new ArrayList<>(ids.size());
|
||||
for (Change.Id id : ids) {
|
||||
@ -277,7 +280,8 @@ public class ChangeIndexer {
|
||||
* @param id change to delete.
|
||||
* @return future for the deleting task.
|
||||
*/
|
||||
public CheckedFuture<?, IOException> deleteAsync(Change.Id id) {
|
||||
@SuppressWarnings("deprecation")
|
||||
public com.google.common.util.concurrent.CheckedFuture<?, IOException> deleteAsync(Change.Id id) {
|
||||
return submit(new DeleteTask(id));
|
||||
}
|
||||
|
||||
@ -300,7 +304,9 @@ public class ChangeIndexer {
|
||||
* @param id ID of the change to index.
|
||||
* @return future for reindexing the change; returns true if the change was stale.
|
||||
*/
|
||||
public CheckedFuture<Boolean, IOException> reindexIfStale(Project.NameKey project, Change.Id id) {
|
||||
@SuppressWarnings("deprecation")
|
||||
public com.google.common.util.concurrent.CheckedFuture<Boolean, IOException> reindexIfStale(
|
||||
Project.NameKey project, Change.Id id) {
|
||||
return submit(new ReindexIfStaleTask(project, id), batchExecutor);
|
||||
}
|
||||
|
||||
@ -324,11 +330,14 @@ public class ChangeIndexer {
|
||||
return indexes != null ? indexes.getWriteIndexes() : Collections.singleton(index);
|
||||
}
|
||||
|
||||
private <T> CheckedFuture<T, IOException> submit(Callable<T> task) {
|
||||
@SuppressWarnings("deprecation")
|
||||
private <T> com.google.common.util.concurrent.CheckedFuture<T, IOException> submit(
|
||||
Callable<T> task) {
|
||||
return submit(task, executor);
|
||||
}
|
||||
|
||||
private static <T> CheckedFuture<T, IOException> submit(
|
||||
@SuppressWarnings("deprecation")
|
||||
private static <T> com.google.common.util.concurrent.CheckedFuture<T, IOException> submit(
|
||||
Callable<T> task, ListeningExecutorService executor) {
|
||||
return Futures.makeChecked(Futures.nonCancellationPropagating(executor.submit(task)), MAPPER);
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ package com.google.gerrit.server.schema;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@ -51,7 +50,9 @@ class NoChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
return new ListResultSet<>(ImmutableList.of());
|
||||
}
|
||||
|
||||
private static <T, K extends Key<?>> CheckedFuture<T, OrmException> emptyFuture() {
|
||||
@SuppressWarnings("deprecation")
|
||||
private static <T, K extends Key<?>>
|
||||
com.google.common.util.concurrent.CheckedFuture<T, OrmException> emptyFuture() {
|
||||
return Futures.immediateCheckedFuture(null);
|
||||
}
|
||||
|
||||
@ -164,8 +165,9 @@ class NoChangesReviewDbWrapper extends ReviewDbWrapper {
|
||||
return empty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public final CheckedFuture<T, OrmException> getAsync(K key) {
|
||||
public final com.google.common.util.concurrent.CheckedFuture<T, OrmException> getAsync(K key) {
|
||||
return emptyFuture();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ import static java.util.Comparator.comparing;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@ -81,7 +80,9 @@ class FusedNoteDbBatchUpdate extends BatchUpdate {
|
||||
setRequestIds(updates, requestId);
|
||||
|
||||
try {
|
||||
List<CheckedFuture<?, IOException>> indexFutures = new ArrayList<>();
|
||||
@SuppressWarnings("deprecation")
|
||||
List<com.google.common.util.concurrent.CheckedFuture<?, IOException>> indexFutures =
|
||||
new ArrayList<>();
|
||||
List<ChangesHandle> handles = new ArrayList<>(updates.size());
|
||||
Order order = getOrder(updates, listener);
|
||||
try {
|
||||
@ -357,12 +358,14 @@ class FusedNoteDbBatchUpdate extends BatchUpdate {
|
||||
FusedNoteDbBatchUpdate.this.batchRefUpdate = manager.execute(dryrun);
|
||||
}
|
||||
|
||||
List<CheckedFuture<?, IOException>> startIndexFutures() {
|
||||
@SuppressWarnings("deprecation")
|
||||
List<com.google.common.util.concurrent.CheckedFuture<?, IOException>> startIndexFutures() {
|
||||
if (dryrun) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
logDebug("Reindexing {} changes", results.size());
|
||||
List<CheckedFuture<?, IOException>> indexFutures = new ArrayList<>(results.size());
|
||||
List<com.google.common.util.concurrent.CheckedFuture<?, IOException>> indexFutures =
|
||||
new ArrayList<>(results.size());
|
||||
for (Map.Entry<Change.Id, ChangeResult> e : results.entrySet()) {
|
||||
Change.Id id = e.getKey();
|
||||
switch (e.getValue()) {
|
||||
|
@ -23,7 +23,6 @@ import static java.util.stream.Collectors.toList;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
@ -321,7 +320,10 @@ class ReviewDbBatchUpdate extends BatchUpdate {
|
||||
private final ReviewDb db;
|
||||
private final SchemaFactory<ReviewDb> schemaFactory;
|
||||
private final long skewMs;
|
||||
private final List<CheckedFuture<?, IOException>> indexFutures = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private final List<com.google.common.util.concurrent.CheckedFuture<?, IOException>> indexFutures =
|
||||
new ArrayList<>();
|
||||
|
||||
@Inject
|
||||
ReviewDbBatchUpdate(
|
||||
|
@ -22,7 +22,6 @@ import static java.util.stream.Collectors.toList;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@ -250,7 +249,8 @@ class UnfusedNoteDbBatchUpdate extends BatchUpdate {
|
||||
private final GitReferenceUpdated gitRefUpdated;
|
||||
private final ReviewDb db;
|
||||
|
||||
private List<CheckedFuture<?, IOException>> indexFutures;
|
||||
@SuppressWarnings("deprecation")
|
||||
private List<com.google.common.util.concurrent.CheckedFuture<?, IOException>> indexFutures;
|
||||
|
||||
@Inject
|
||||
UnfusedNoteDbBatchUpdate(
|
||||
|
Loading…
Reference in New Issue
Block a user