https://firebase.google.com/support/release-notes/admin/java

сто пытаюсь решить заметки об устаревании из своего Java-кода нового Firebase-Admin SDK, код написан в версии 5.3.1, но после обновления версии до 5.5.0 появились примечания об устаревании, вот пример моего код:

С помощьюFirebaseAuth (устарела на:Task, addOnSuccessListener а такжеaddOnFailureListener):

private CompletableFuture<FirebaseToken> getDecryptedTokenCompletableFuture(String firebaseTokenString) {
        CompletableFuture<FirebaseToken> tokenFuture = new CompletableFuture<>();
        Task<FirebaseToken> tokenTask = FirebaseAuth.getInstance(firebaseApp).verifyIdToken(firebaseTokenString);
        tokenTask.addOnSuccessListener(tokenFuture::complete);
        tokenTask.addOnFailureListener(exception -> tokenFuture.completeExceptionally(new AuthorizationException("Failed to verify token", exception)));
        return tokenFuture;
    }

И дляFirebaseDatabase (устарела на:Task, addOnSuccessListener, addOnFailureListener, updateChildren а такжеremoveValue):

public static <T> CompletableFuture<T> toCompletableFuture(Task<T> task) {
    CompletableFuture<T> future = new CompletableFuture<>();
    task.addOnCompleteListener(result -> {
        future.complete(result.getResult());
    }).addOnFailureListener(future::completeExceptionally);
    return future;
}

/**
 * @param updatedParams if null it will removed child
 * @param path          path to update
 * @return void when complete
 */
public CompletableFuture<Void> updateObjectData(Map<String, Object> updatedParams, String path) {
    if (updatedParams == null) {
        return removeObjectData(path);
    }
    logger.debug("Update ObjectData in firebase of ref ({}) with data: {}", path, updatedParams.toString());
    DatabaseReference child = this.getUserDataReference().child(path);
    return toCompletableFuture(child.updateChildren(updatedParams));
}

/**
 * @param path path to of node to remove
 * @return void when complete
 */
public CompletableFuture<Void> removeObjectData(String path) {
    logger.debug("Remove ObjectData in firebase of ref ({})", path);
    DatabaseReference child = this.getUserDataReference().child(path);
    return toCompletableFuture(child.removeValue());
}

Примечание амортизации, скажем, я должен использоватьApiFuture как говорится в примечаниях к выпуску:https://firebase.google.com/support/release-notes/admin/java

И внутри источника, как, например:

  /**
   * Similar to {@link #updateChildrenAsync(Map)} but returns a Task.
   *
   * @param update The paths to update and their new values
   * @return The {@link Task} for this operation.
   * @deprecated Use {@link #updateChildrenAsync(Map)}
   */

А также

/**
 * Represents an asynchronous operation.
 *
 * @param <T> the type of the result of the operation
 * @deprecated {@code Task} has been deprecated in favor of
 *     <a href="https://googleapis.github.io/api-common-java/1.1.0/apidocs/com/google/api/core/ApiFuture.html">{@code ApiFuture}</a>.
 *     For every method x() that returns a {@code Task<T>}, you should be able to find a
 *     corresponding xAsync() method that returns an {@code ApiFuture<T>}.
 */

Ответы на вопрос(2)

Ваш ответ на вопрос