From 78c7e5cf1455ae708a49360504fc0fd611572a3f Mon Sep 17 00:00:00 2001 From: crafter23456 <64259198+crafter23456@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:59:34 +0200 Subject: [PATCH 1/2] remove unused commands --- .../java/com/google/common/base/Objects.java | 451 ----- .../common/util/concurrent/Futures.java | 1670 ----------------- .../common/util/concurrent/MoreExecutors.java | 1172 ------------ .../command/defaults/AchievementCommand.java | 188 -- .../bukkit/command/defaults/BanCommand.java | 56 - .../bukkit/command/defaults/BanIpCommand.java | 78 - .../command/defaults/BanListCommand.java | 72 - .../bukkit/command/defaults/ClearCommand.java | 115 -- .../defaults/DefaultGameModeCommand.java | 71 - .../bukkit/command/defaults/DeopCommand.java | 63 - .../command/defaults/DifficultyCommand.java | 82 - .../command/defaults/EffectCommand.java | 120 -- .../command/defaults/EnchantCommand.java | 170 -- .../bukkit/command/defaults/ExpCommand.java | 90 - .../command/defaults/GameModeCommand.java | 101 - .../command/defaults/GameRuleCommand.java | 89 - .../bukkit/command/defaults/GiveCommand.java | 130 -- .../bukkit/command/defaults/KickCommand.java | 60 - .../bukkit/command/defaults/KillCommand.java | 51 - .../bukkit/command/defaults/ListCommand.java | 55 - .../bukkit/command/defaults/MeCommand.java | 36 - .../bukkit/command/defaults/OpCommand.java | 76 - .../command/defaults/PardonCommand.java | 57 - .../command/defaults/PardonIpCommand.java | 53 - .../command/defaults/PlaySoundCommand.java | 88 - .../bukkit/command/defaults/SaveCommand.java | 47 - .../command/defaults/SaveOffCommand.java | 42 - .../command/defaults/SaveOnCommand.java | 42 - .../bukkit/command/defaults/SayCommand.java | 61 - .../command/defaults/ScoreboardCommand.java | 618 ------ .../bukkit/command/defaults/SeedCommand.java | 42 - .../defaults/SetIdleTimeoutCommand.java | 54 - .../defaults/SetWorldSpawnCommand.java | 80 - .../command/defaults/SpawnpointCommand.java | 88 - .../defaults/SpreadPlayersCommand.java | 266 --- .../bukkit/command/defaults/StopCommand.java | 49 - .../command/defaults/TeleportCommand.java | 125 -- .../bukkit/command/defaults/TellCommand.java | 61 - .../command/defaults/TestForCommand.java | 38 - .../bukkit/command/defaults/TimeCommand.java | 89 - .../defaults/ToggleDownfallCommand.java | 57 - .../command/defaults/WeatherCommand.java | 74 - .../command/defaults/WhitelistCommand.java | 128 -- .../org/bukkit/enchantments/Enchantment.java | 2 - 44 files changed, 7157 deletions(-) delete mode 100644 NachoSpigot-API/src/main/java/com/google/common/base/Objects.java delete mode 100644 NachoSpigot-API/src/main/java/com/google/common/util/concurrent/Futures.java delete mode 100644 NachoSpigot-API/src/main/java/com/google/common/util/concurrent/MoreExecutors.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/AchievementCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanIpCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanListCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ClearCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DefaultGameModeCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DeopCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DifficultyCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/EffectCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/EnchantCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ExpCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GameModeCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GameRuleCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GiveCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/KickCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/KillCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ListCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/MeCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/OpCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PardonCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PardonIpCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveOffCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveOnCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SayCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SeedCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SetIdleTimeoutCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SetWorldSpawnCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SpawnpointCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SpreadPlayersCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/StopCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TeleportCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TellCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TestForCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TimeCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ToggleDownfallCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/WeatherCommand.java delete mode 100644 NachoSpigot-API/src/main/java/org/bukkit/command/defaults/WhitelistCommand.java diff --git a/NachoSpigot-API/src/main/java/com/google/common/base/Objects.java b/NachoSpigot-API/src/main/java/com/google/common/base/Objects.java deleted file mode 100644 index 0101907a6..000000000 --- a/NachoSpigot-API/src/main/java/com/google/common/base/Objects.java +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright (C) 2007 The Guava Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.common.base; - -import com.google.common.annotations.GwtCompatible; - -import javax.annotation.CheckReturnValue; -import javax.annotation.Nullable; -import java.util.Arrays; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Helper functions that can operate on any {@code Object}. - * - *
See the Guava User Guide on writing - * {@code Object} methods with {@code Objects}. - * - * @author Laurence Gonsalves - * @since 2.0 (imported from Google Collections Library) - */ -@GwtCompatible -public final class Objects { - private Objects() {} - - /** - * Determines whether two possibly-null objects are equal. Returns: - * - *
This assumes that any non-null objects passed to this function conform - * to the {@code equals()} contract. - */ - @CheckReturnValue - public static boolean equal(@Nullable Object a, @Nullable Object b) { - return java.util.Objects.equals(a, b); // Nacho - } - - /** - * Generates a hash code for multiple values. The hash code is generated by - * calling {@link Arrays#hashCode(Object[])}. Note that array arguments to - * this method, with the exception of a single Object array, do not get any - * special handling; their hash codes are based on identity and not contents. - * - *
This is useful for implementing {@link Object#hashCode()}. For example, - * in an object that has three properties, {@code x}, {@code y}, and - * {@code z}, one could write: - *
{@code - * public int hashCode() { - * return Objects.hashCode(getX(), getY(), getZ()); - * }}- * - *
Warning: When a single object is supplied, the returned hash code - * does not equal the hash code of that object. - */ - public static int hashCode(@Nullable Object... objects) { - return Arrays.hashCode(objects); - } - - // Nacho start - /** - * Creates an instance of {@link ToStringHelper}. - * - *
This is helpful for implementing {@link Object#toString()}. - * Specification by example:
{@code - * // Returns "ClassName{}" - * Objects.toStringHelper(this) - * .toString(); - * - * // Returns "ClassName{x=1}" - * Objects.toStringHelper(this) - * .add("x", 1) - * .toString(); - * - * // Returns "MyObject{x=1}" - * Objects.toStringHelper("MyObject") - * .add("x", 1) - * .toString(); - * - * // Returns "ClassName{x=1, y=foo}" - * Objects.toStringHelper(this) - * .add("x", 1) - * .add("y", "foo") - * .toString(); - * - * // Returns "ClassName{x=1}" - * Objects.toStringHelper(this) - * .omitNullValues() - * .add("x", 1) - * .add("y", null) - * .toString(); - * }}- * - *
Note that in GWT, class names are often obfuscated. - * - * @param self the object to generate the string for (typically {@code this}), - * used only for its class name - * @since 2.0 - * @deprecated replaced by {@link MoreObjects#toStringHelper(Object)} - * @see MoreObjects#toStringHelper(Object) - */ - @Deprecated - public static ToStringHelper toStringHelper(Object self) { - return new ToStringHelper(simpleName(self.getClass())); - } - - /** - * Creates an instance of {@link ToStringHelper} in the same manner as - * {@link Objects#toStringHelper(Object)}, but using the name of {@code clazz} - * instead of using an instance's {@link Object#getClass()}. - * - *
Note that in GWT, class names are often obfuscated. - * - * @param clazz the {@link Class} of the instance - * @since 7.0 (source-compatible since 2.0) - * @deprecated replaced by {@link MoreObjects#toStringHelper(Class)} - * @see MoreObjects#toStringHelper(Class) - */ - @Deprecated - public static ToStringHelper toStringHelper(Class> clazz) { - return new ToStringHelper(simpleName(clazz)); - } - - /** - * Creates an instance of {@link ToStringHelper} in the same manner as - * {@link Objects#toStringHelper(Object)}, but using {@code className} instead - * of using an instance's {@link Object#getClass()}. - * - * @param className the name of the instance type - * @since 7.0 (source-compatible since 2.0) - * @deprecated replaced by {@link MoreObjects#toStringHelper(String)} - * @see MoreObjects#toStringHelper(String) - */ - @Deprecated - public static ToStringHelper toStringHelper(String className) { - return new ToStringHelper(className); - } - - /** - * {@link Class#getSimpleName()} is not GWT compatible yet, so we - * provide our own implementation. - * @deprecated {@link Class#getSimpleName()} is now GWT compatible, use it instead - * @see Class#getSimpleName() - */ - @Deprecated - private static String simpleName(Class> clazz) { - String name = clazz.getName(); - - // the nth anonymous class has a class name ending in "Outer$n" - // and local inner classes have names ending in "Outer.$1Inner" - name = name.replaceAll("\\$[0-9]+", "\\$"); - - // we want the name of the inner class all by its lonesome - int start = name.lastIndexOf('$'); - - // if this isn't an inner class, just find the start of the - // top level class name. - if (start == -1) { - start = name.lastIndexOf('.'); - } - return name.substring(start + 1); - } - - /** - * Returns the first of two given parameters that is not {@code null}, if - * either is, or otherwise throws a {@link NullPointerException}. - * - *
Note: if {@code first} is represented as an {@link Optional},
- * this can be accomplished with
- * {@linkplain Optional#or(Object) first.or(second)}.
- * That approach also allows for lazy evaluation of the fallback instance,
- * using {@linkplain Optional#or(Supplier) first.or(Supplier)}.
- *
- * @return {@code first} if {@code first} is not {@code null}, or
- * {@code second} if {@code first} is {@code null} and {@code second} is
- * not {@code null}
- * @throws NullPointerException if both {@code first} and {@code second} were
- * {@code null}
- * @since 3.0
- * @deprecated replaced by {@link MoreObjects#firstNonNull(Object, Object)}
- * @see MoreObjects#firstNonNull(Object, Object)
- */
- @Deprecated
- public static It is strongly encouraged to use {@link #add(String, Object)} instead
- * and give value a readable name.
- */
- public ToStringHelper addValue(@Nullable Object value) {
- return addHolder(value);
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- * It is strongly encouraged to use {@link #add(String, boolean)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(boolean value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- * It is strongly encouraged to use {@link #add(String, char)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(char value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- * It is strongly encouraged to use {@link #add(String, double)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(double value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- * It is strongly encouraged to use {@link #add(String, float)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(float value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- * It is strongly encouraged to use {@link #add(String, int)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(int value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Adds an unnamed value to the formatted output.
- *
- * It is strongly encouraged to use {@link #add(String, long)} instead
- * and give value a readable name.
- *
- * @since 11.0 (source-compatible since 2.0)
- */
- public ToStringHelper addValue(long value) {
- return addHolder(String.valueOf(value));
- }
-
- /**
- * Returns a string in the format specified by {@link
- * Objects#toStringHelper(Object)}.
- *
- * After calling this method, you can keep adding more properties to later
- * call toString() again and get a more complete representation of the
- * same object; but properties cannot be removed, so this only allows
- * limited reuse of the helper instance. The helper allows duplication of
- * properties (multiple name/value pairs with the same name can be added).
- */
- @Override public String toString() {
- // create a copy to keep it consistent in case value changes
- boolean omitNullValuesSnapshot = omitNullValues;
- String nextSeparator = "";
- StringBuilder builder = new StringBuilder(32).append(className)
- .append('{');
- for (ValueHolder valueHolder = holderHead.next; valueHolder != null;
- valueHolder = valueHolder.next) {
- if (!omitNullValuesSnapshot || valueHolder.value != null) {
- builder.append(nextSeparator);
- nextSeparator = ", ";
-
- if (valueHolder.name != null) {
- builder.append(valueHolder.name).append('=');
- }
- builder.append(valueHolder.value);
- }
- }
- return builder.append('}').toString();
- }
-
- private ValueHolder addHolder() {
- ValueHolder valueHolder = new ValueHolder();
- holderTail = holderTail.next = valueHolder;
- return valueHolder;
- }
-
- private ToStringHelper addHolder(@Nullable Object value) {
- ValueHolder valueHolder = addHolder();
- valueHolder.value = value;
- return this;
- }
-
- private ToStringHelper addHolder(String name, @Nullable Object value) {
- ValueHolder valueHolder = addHolder();
- valueHolder.value = value;
- valueHolder.name = checkNotNull(name);
- return this;
- }
-
- private static final class ValueHolder {
- String name;
- Object value;
- ValueHolder next;
- }
- }
- // Nacho end
-}
\ No newline at end of file
diff --git a/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/Futures.java b/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/Futures.java
deleted file mode 100644
index 03dc028d9..000000000
--- a/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/Futures.java
+++ /dev/null
@@ -1,1670 +0,0 @@
-/*
- * Copyright (C) 2006 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.common.util.concurrent;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.util.concurrent.Internal.toNanosSaturated;
-import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
-import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.Beta;
-import com.google.common.annotations.GwtCompatible;
-import com.google.common.annotations.GwtIncompatible;
-import com.google.common.base.Function;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.util.concurrent.CollectionFuture.ListFuture;
-import com.google.common.util.concurrent.ImmediateFuture.ImmediateCancelledFuture;
-import com.google.common.util.concurrent.ImmediateFuture.ImmediateFailedFuture;
-import com.google.common.util.concurrent.internal.InternalFutureFailureAccess;
-import com.google.common.util.concurrent.internal.InternalFutures;
-import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import java.time.Duration;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Future;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.annotation.CheckForNull;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * Static utility methods pertaining to the {@link Future} interface.
- *
- * Many of these methods use the {@link ListenableFuture} API; consult the Guava User Guide
- * article on {@code
- * ListenableFuture}.
- *
- * The main purpose of {@code ListenableFuture} is to help you chain together a graph of
- * asynchronous operations. You can chain them together manually with calls to methods like {@link
- * Futures#transform(ListenableFuture, Function, Executor) Futures.transform}, but you will often
- * find it easier to use a framework. Frameworks automate the process, often adding features like
- * monitoring, debugging, and cancellation. Examples of frameworks include:
- *
- * If you do chain your operations manually, you may want to use {@link FluentFuture}.
- *
- * @author Kevin Bourrillion
- * @author Nishant Thakkar
- * @author Sven Mawson
- * @since 1.0
- */
-@GwtCompatible(emulated = true)
-@ElementTypesAreNonnullByDefault
-public final class Futures extends GwtFuturesCatchingSpecialization {
-
- // A note on memory visibility.
- // Many of the utilities in this class (transform, withFallback, withTimeout, asList, combine)
- // have two requirements that significantly complicate their design.
- // 1. Cancellation should propagate from the returned future to the input future(s).
- // 2. The returned futures shouldn't unnecessarily 'pin' their inputs after completion.
- //
- // A consequence of these requirements is that the delegate futures cannot be stored in
- // final fields.
- //
- // For simplicity the rest of this description will discuss Futures.catching since it is the
- // simplest instance, though very similar descriptions apply to many other classes in this file.
- //
- // In the constructor of AbstractCatchingFuture, the delegate future is assigned to a field
- // 'inputFuture'. That field is non-final and non-volatile. There are 2 places where the
- // 'inputFuture' field is read and where we will have to consider visibility of the write
- // operation in the constructor.
- //
- // 1. In the listener that performs the callback. In this case it is fine since inputFuture is
- // assigned prior to calling addListener, and addListener happens-before any invocation of the
- // listener. Notably, this means that 'volatile' is unnecessary to make 'inputFuture' visible
- // to the listener.
- //
- // 2. In done() where we may propagate cancellation to the input. In this case it is _not_ fine.
- // There is currently nothing that enforces that the write to inputFuture in the constructor is
- // visible to done(). This is because there is no happens before edge between the write and a
- // (hypothetical) unsafe read by our caller. Note: adding 'volatile' does not fix this issue,
- // it would just add an edge such that if done() observed non-null, then it would also
- // definitely observe all earlier writes, but we still have no guarantee that done() would see
- // the inital write (just stronger guarantees if it does).
- //
- // See: http://cs.oswego.edu/pipermail/concurrency-interest/2015-January/013800.html
- // For a (long) discussion about this specific issue and the general futility of life.
- //
- // For the time being we are OK with the problem discussed above since it requires a caller to
- // introduce a very specific kind of data-race. And given the other operations performed by these
- // methods that involve volatile read/write operations, in practice there is no issue. Also, the
- // way in such a visibility issue would surface is most likely as a failure of cancel() to
- // propagate to the input. Cancellation propagation is fundamentally racy so this is fine.
- //
- // Future versions of the JMM may revise safe construction semantics in such a way that we can
- // safely publish these objects and we won't need this whole discussion.
- // TODO(user,lukes): consider adding volatile to all these fields since in current known JVMs
- // that should resolve the issue. This comes at the cost of adding more write barriers to the
- // implementations.
-
- private Futures() {}
-
- /**
- * Creates a {@code ListenableFuture} which has its value set immediately upon construction. The
- * getters just return the value. This {@code Future} can't be canceled or timed out and its
- * {@code isDone()} method always returns {@code true}.
- */
- public static The returned {@code Future} can't be cancelled, and its {@code isDone()} method always
- * returns {@code true}. Calling {@code get()} will immediately throw the provided {@code
- * Throwable} wrapped in an {@code ExecutionException}.
- */
- public static Usage example:
- *
- * When selecting an executor, note that {@code directExecutor} is dangerous in some cases. See
- * the warnings the {@link MoreExecutors#directExecutor} documentation.
- *
- * @param input the primary input {@code Future}
- * @param exceptionType the exception type that triggers use of {@code fallback}. The exception
- * type is matched against the input's exception. "The input's exception" means the cause of
- * the {@link ExecutionException} thrown by {@code input.get()} or, if {@code get()} throws a
- * different kind of exception, that exception itself. To avoid hiding bugs and other
- * unrecoverable errors, callers should prefer more specific types, avoiding {@code
- * Throwable.class} in particular.
- * @param fallback the {@link Function} to be called if {@code input} fails with the expected
- * exception type. The function's argument is the input's exception. "The input's exception"
- * means the cause of the {@link ExecutionException} thrown by {@code input.get()} or, if
- * {@code get()} throws a different kind of exception, that exception itself.
- * @param executor the executor that runs {@code fallback} if {@code input} fails
- * @since 19.0
- */
- @Beta
- @Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
- public static Usage examples:
- *
- * The fallback can also choose to propagate the original exception when desired:
- *
- * When selecting an executor, note that {@code directExecutor} is dangerous in some cases. See
- * the warnings the {@link MoreExecutors#directExecutor} documentation.
- *
- * @param input the primary input {@code Future}
- * @param exceptionType the exception type that triggers use of {@code fallback}. The exception
- * type is matched against the input's exception. "The input's exception" means the cause of
- * the {@link ExecutionException} thrown by {@code input.get()} or, if {@code get()} throws a
- * different kind of exception, that exception itself. To avoid hiding bugs and other
- * unrecoverable errors, callers should prefer more specific types, avoiding {@code
- * Throwable.class} in particular.
- * @param fallback the {@link AsyncFunction} to be called if {@code input} fails with the expected
- * exception type. The function's argument is the input's exception. "The input's exception"
- * means the cause of the {@link ExecutionException} thrown by {@code input.get()} or, if
- * {@code get()} throws a different kind of exception, that exception itself.
- * @param executor the executor that runs {@code fallback} if {@code input} fails
- * @since 19.0 (similar functionality in 14.0 as {@code withFallback})
- */
- @Beta
- @Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
- public static The delegate future is interrupted and cancelled if it times out.
- *
- * @param delegate The future to delegate to.
- * @param time when to timeout the future
- * @param scheduledExecutor The executor service to enforce the timeout.
- * @since 28.0
- */
- @Beta
- @GwtIncompatible // java.util.concurrent.ScheduledExecutorService
- public static The delegate future is interrupted and cancelled if it times out.
- *
- * @param delegate The future to delegate to.
- * @param time when to timeout the future
- * @param unit the time unit of the time parameter
- * @param scheduledExecutor The executor service to enforce the timeout.
- * @since 19.0
- */
- @Beta
- @GwtIncompatible // java.util.concurrent.ScheduledExecutorService
- @SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static More precisely, the returned {@code Future} takes its result from a {@code Future} produced
- * by applying the given {@code AsyncFunction} to the result of the original {@code Future}.
- * Example usage:
- *
- * When selecting an executor, note that {@code directExecutor} is dangerous in some cases. See
- * the warnings the {@link MoreExecutors#directExecutor} documentation.
- *
- * The returned {@code Future} attempts to keep its cancellation state in sync with that of the
- * input future and that of the future returned by the chain function. That is, if the returned
- * {@code Future} is cancelled, it will attempt to cancel the other two, and if either of the
- * other two is cancelled, the returned {@code Future} will receive a callback in which it will
- * attempt to cancel itself.
- *
- * @param input The future to transform
- * @param function A function to transform the result of the input future to the result of the
- * output future
- * @param executor Executor to run the function in.
- * @return A future that holds result of the function (if the input succeeded) or the original
- * input's failure (if not)
- * @since 19.0 (in 11.0 as {@code transform})
- */
- @Beta
- public static
- ListenableFuture When selecting an executor, note that {@code directExecutor} is dangerous in some cases. See
- * the warnings the {@link MoreExecutors#directExecutor} documentation.
- *
- * The returned {@code Future} attempts to keep its cancellation state in sync with that of the
- * input future. That is, if the returned {@code Future} is cancelled, it will attempt to cancel
- * the input, and if the input is cancelled, the returned {@code Future} will receive a callback
- * in which it will attempt to cancel itself.
- *
- * An example use of this method is to convert a serializable object returned from an RPC into
- * a POJO.
- *
- * @param input The future to transform
- * @param function A Function to transform the results of the provided future to the results of
- * the returned future.
- * @param executor Executor to run the function in.
- * @return A future that holds result of the transformation.
- * @since 9.0 (in 2.0 as {@code compose})
- */
- @Beta
- public static
- ListenableFuture The returned {@code Future} reflects the input's cancellation state directly, and any
- * attempt to cancel the returned Future is likewise passed through to the input Future.
- *
- * Note that calls to {@linkplain Future#get(long, TimeUnit) timed get} only apply the timeout
- * to the execution of the underlying {@code Future}, not to the execution of the
- * transformation function.
- *
- * The primary audience of this method is callers of {@code transform} who don't have a {@code
- * ListenableFuture} available and do not mind repeated, lazy function evaluation.
- *
- * @param input The future to transform
- * @param function A Function to transform the results of the provided future to the results of
- * the returned future.
- * @return A future that returns the result of the transformation.
- * @since 10.0
- */
- @Beta
- @GwtIncompatible // TODO
- public static Future The list of results is in the same order as the input list.
- *
- * This differs from {@link #successfulAsList(ListenableFuture[])} in that it will return a
- * failed future if any of the items fails.
- *
- * Canceling this future will attempt to cancel all the component futures, and if any of the
- * provided futures fails or is canceled, this one is, too.
- *
- * @param futures futures to combine
- * @return a future that provides a list of the results of the component futures
- * @since 10.0
- */
- @Beta
- @SafeVarargs
- public static The list of results is in the same order as the input list.
- *
- * This differs from {@link #successfulAsList(Iterable)} in that it will return a failed future
- * if any of the items fails.
- *
- * Canceling this future will attempt to cancel all the component futures, and if any of the
- * provided futures fails or is canceled, this one is, too.
- *
- * @param futures futures to combine
- * @return a future that provides a list of the results of the component futures
- * @since 10.0
- */
- @Beta
- public static Any failures from the input futures will not be propagated to the returned future.
- *
- * @since 20.0
- */
- @Beta
- @SafeVarargs
- public static Any failures from the input futures will not be propagated to the returned future.
- *
- * @since 20.0
- */
- @Beta
- public static If any input fails, the returned future fails immediately.
- *
- * @since 20.0
- */
- @Beta
- @SafeVarargs
- public static If any input fails, the returned future fails immediately.
- *
- * @since 20.0
- */
- @Beta
- public static See {@link #whenAllComplete} and {@link #whenAllSucceed} for how to instantiate this class.
- *
- * Example:
- *
- * If the combiner throws a {@code CancellationException}, the returned future will be
- * cancelled.
- *
- * If the combiner throws an {@code ExecutionException}, the cause of the thrown {@code
- * ExecutionException} will be extracted and returned as the cause of the new {@code
- * ExecutionException} that gets thrown by the returned combined future.
- *
- * Canceling this future will attempt to cancel all the component futures.
- */
- public If the combiner throws a {@code CancellationException}, the returned future will be
- * cancelled.
- *
- * If the combiner throws an {@code ExecutionException}, the cause of the thrown {@code
- * ExecutionException} will be extracted and returned as the cause of the new {@code
- * ExecutionException} that gets thrown by the returned combined future.
- *
- * Canceling this future will attempt to cancel all the component futures.
- */
- @CanIgnoreReturnValue // TODO(cpovirk): Remove this
- public If the combiner throws a {@code CancellationException}, the returned future will be
- * cancelled.
- *
- * Canceling this Future will attempt to cancel all the component futures.
- *
- * @since 23.6
- */
- public ListenableFuture> run(final Runnable combiner, Executor executor) {
- return call(
- new Callable<@Nullable Void>() {
- @Override
- @CheckForNull
- public Void call() throws Exception {
- combiner.run();
- return null;
- }
- },
- executor);
- }
- }
-
- /**
- * Returns a {@code ListenableFuture} whose result is set from the supplied future when it
- * completes. Cancelling the supplied future will also cancel the returned future, but cancelling
- * the returned future will have no effect on the supplied future.
- *
- * @since 15.0
- */
- public static The list of results is in the same order as the input list.
- *
- * This differs from {@link #allAsList(ListenableFuture[])} in that it's tolerant of failed
- * futures for any of the items, representing them as {@code null} in the result list.
- *
- * Canceling this future will attempt to cancel all the component futures.
- *
- * @param futures futures to combine
- * @return a future that provides a list of the results of the component futures
- * @since 10.0
- */
- @Beta
- @SafeVarargs
- public static The list of results is in the same order as the input list.
- *
- * This differs from {@link #allAsList(Iterable)} in that it's tolerant of failed futures for
- * any of the items, representing them as {@code null} in the result list.
- *
- * Canceling this future will attempt to cancel all the component futures.
- *
- * @param futures futures to combine
- * @return a future that provides a list of the results of the component futures
- * @since 10.0
- */
- @Beta
- public static "In the order that they complete" means, for practical purposes, about what you would
- * expect, but there are some subtleties. First, we do guarantee that, if the output future at
- * index n is done, the output future at index n-1 is also done. (But as usual with futures, some
- * listeners for future n may complete before some for future n-1.) However, it is possible, if
- * one input completes with result X and another later with result Y, for Y to come before X in
- * the output future list. (Such races are impossible to solve without global synchronization of
- * all future completions. And they should have little practical impact.)
- *
- * Cancelling a delegate future propagates to input futures once all the delegates complete,
- * either from cancellation or because an input future has completed. If N futures are passed in,
- * and M delegates are cancelled, the remaining M input futures will be cancelled once N - M of
- * the input futures complete. If all the delegates are cancelled, all the input futures will be
- * too.
- *
- * @since 17.0
- */
- public static The callback is run on {@code executor}. There is no guaranteed ordering of execution of
- * callbacks, but any callback added through this method is guaranteed to be called once the
- * computation is complete.
- *
- * Exceptions thrown by a {@code callback} will be propagated up to the executor. Any exception
- * thrown during {@code Executor.execute} (e.g., a {@code RejectedExecutionException} or an
- * exception thrown by {@linkplain MoreExecutors#directExecutor direct execution}) will be caught
- * and logged.
- *
- * Example:
- *
- * When selecting an executor, note that {@code directExecutor} is dangerous in some cases. See
- * the warnings the {@link MoreExecutors#directExecutor} documentation.
- *
- * For a more general interface to attach a completion listener to a {@code Future}, see {@link
- * ListenableFuture#addListener addListener}.
- *
- * @param future The future attach the callback to.
- * @param callback The callback to invoke when {@code future} is completed.
- * @param executor The executor to run {@code callback} when the future completes.
- * @since 10.0
- */
- public static The benefits of this method are twofold. First, the name "getDone" suggests to readers that
- * the {@code Future} is already done. Second, if buggy code calls {@code getDone} on a {@code
- * Future} that is still pending, the program will throw instead of block. This can be important
- * for APIs like {@link #whenAllComplete whenAllComplete(...)}{@code .}{@link
- * FutureCombiner#call(Callable, Executor) call(...)}, where it is easy to use a new input from
- * the {@code call} implementation but forget to add it to the arguments of {@code
- * whenAllComplete}.
- *
- * If you are looking for a method to determine whether a given {@code Future} is done, use the
- * instance method {@link Future#isDone()}.
- *
- * @throws ExecutionException if the {@code Future} failed with an exception
- * @throws CancellationException if the {@code Future} was cancelled
- * @throws IllegalStateException if the {@code Future} is not done
- * @since 20.0
- */
- @CanIgnoreReturnValue
- // TODO(cpovirk): Consider calling getDone() in our own code.
- @ParametricNullness
- public static Exceptions from {@code Future.get} are treated as follows:
- *
- * The overall principle is to continue to treat every checked exception as a checked
- * exception, every unchecked exception as an unchecked exception, and every error as an error. In
- * addition, the cause of any {@code ExecutionException} is wrapped in order to ensure that the
- * new stack trace matches that of the current thread.
- *
- * Instances of {@code exceptionClass} are created by choosing an arbitrary public constructor
- * that accepts zero or more arguments, all of type {@code String} or {@code Throwable}
- * (preferring constructors with at least one {@code String}) and calling the constructor via
- * reflection. If the exception did not already have a cause, one is set by calling {@link
- * Throwable#initCause(Throwable)} on it. If no such constructor exists, an {@code
- * IllegalArgumentException} is thrown.
- *
- * @throws X if {@code get} throws any checked exception except for an {@code ExecutionException}
- * whose cause is not itself a checked exception
- * @throws UncheckedExecutionException if {@code get} throws an {@code ExecutionException} with a
- * {@code RuntimeException} as its cause
- * @throws ExecutionError if {@code get} throws an {@code ExecutionException} with an {@code
- * Error} as its cause
- * @throws CancellationException if {@code get} throws a {@code CancellationException}
- * @throws IllegalArgumentException if {@code exceptionClass} extends {@code RuntimeException} or
- * does not have a suitable constructor
- * @since 19.0 (in 10.0 as {@code get})
- */
- @Beta
- @CanIgnoreReturnValue
- @GwtIncompatible // reflection
- @ParametricNullness
- public static Exceptions from {@code Future.get} are treated as follows:
- *
- * The overall principle is to continue to treat every checked exception as a checked
- * exception, every unchecked exception as an unchecked exception, and every error as an error. In
- * addition, the cause of any {@code ExecutionException} is wrapped in order to ensure that the
- * new stack trace matches that of the current thread.
- *
- * Instances of {@code exceptionClass} are created by choosing an arbitrary public constructor
- * that accepts zero or more arguments, all of type {@code String} or {@code Throwable}
- * (preferring constructors with at least one {@code String}) and calling the constructor via
- * reflection. If the exception did not already have a cause, one is set by calling {@link
- * Throwable#initCause(Throwable)} on it. If no such constructor exists, an {@code
- * IllegalArgumentException} is thrown.
- *
- * @throws X if {@code get} throws any checked exception except for an {@code ExecutionException}
- * whose cause is not itself a checked exception
- * @throws UncheckedExecutionException if {@code get} throws an {@code ExecutionException} with a
- * {@code RuntimeException} as its cause
- * @throws ExecutionError if {@code get} throws an {@code ExecutionException} with an {@code
- * Error} as its cause
- * @throws CancellationException if {@code get} throws a {@code CancellationException}
- * @throws IllegalArgumentException if {@code exceptionClass} extends {@code RuntimeException} or
- * does not have a suitable constructor
- * @since 28.0
- */
- @Beta
- @CanIgnoreReturnValue
- @GwtIncompatible // reflection
- @ParametricNullness
- public static Exceptions from {@code Future.get} are treated as follows:
- *
- * The overall principle is to continue to treat every checked exception as a checked
- * exception, every unchecked exception as an unchecked exception, and every error as an error. In
- * addition, the cause of any {@code ExecutionException} is wrapped in order to ensure that the
- * new stack trace matches that of the current thread.
- *
- * Instances of {@code exceptionClass} are created by choosing an arbitrary public constructor
- * that accepts zero or more arguments, all of type {@code String} or {@code Throwable}
- * (preferring constructors with at least one {@code String}) and calling the constructor via
- * reflection. If the exception did not already have a cause, one is set by calling {@link
- * Throwable#initCause(Throwable)} on it. If no such constructor exists, an {@code
- * IllegalArgumentException} is thrown.
- *
- * @throws X if {@code get} throws any checked exception except for an {@code ExecutionException}
- * whose cause is not itself a checked exception
- * @throws UncheckedExecutionException if {@code get} throws an {@code ExecutionException} with a
- * {@code RuntimeException} as its cause
- * @throws ExecutionError if {@code get} throws an {@code ExecutionException} with an {@code
- * Error} as its cause
- * @throws CancellationException if {@code get} throws a {@code CancellationException}
- * @throws IllegalArgumentException if {@code exceptionClass} extends {@code RuntimeException} or
- * does not have a suitable constructor
- * @since 19.0 (in 10.0 as {@code get} and with different parameter order)
- */
- @Beta
- @CanIgnoreReturnValue
- @GwtIncompatible // reflection
- @SuppressWarnings("GoodTime") // should accept a java.time.Duration
- @ParametricNullness
- public static Exceptions from {@code Future.get} are treated as follows:
- *
- * The overall principle is to eliminate all checked exceptions: to loop to avoid {@code
- * InterruptedException}, to pass through {@code CancellationException}, and to wrap any exception
- * from the underlying computation in an {@code UncheckedExecutionException} or {@code
- * ExecutionError}.
- *
- * For an uninterruptible {@code get} that preserves other exceptions, see {@link
- * Uninterruptibles#getUninterruptibly(Future)}.
- *
- * @throws UncheckedExecutionException if {@code get} throws an {@code ExecutionException} with an
- * {@code Exception} as its cause
- * @throws ExecutionError if {@code get} throws an {@code ExecutionException} with an {@code
- * Error} as its cause
- * @throws CancellationException if {@code get} throws a {@code CancellationException}
- * @since 10.0
- */
- @CanIgnoreReturnValue
- @ParametricNullness
- public static There is no guaranteed ordering of execution of callbacks, but any callback added through
- * this method is guaranteed to be called once the computation is complete.
- *
- * Example:
- *
- * This overload, which does not accept an executor, uses {@code directExecutor}, a dangerous
- * choice in some cases. See the discussion in the {@link ListenableFuture#addListener
- * ListenableFuture.addListener} documentation. All its warnings about heavyweight listeners are
- * also applicable to heavyweight callbacks passed to this method.
- *
- * For a more general interface to attach a completion listener to a {@code Future}, see {@link
- * ListenableFuture#addListener addListener}.
- *
- * @param future The future attach the callback to.
- * @param callback The callback to invoke when {@code future} is completed.
- * @since 10.0
- * @deprecated Use {@linkplain #addCallback(ListenableFuture, FutureCallback, Executor) the
- * overload that requires an executor}. For identical behavior, pass {@link
- * MoreExecutors#directExecutor}, but consider whether another executor would be safer, as
- * discussed in the {@link ListenableFuture#addListener ListenableFuture.addListener}
- * documentation. This method is scheduled to be removed in July 2018.
- */
- @Deprecated
- @com.google.errorprone.annotations.DoNotCall
- public static This overload, which does not accept an executor, uses {@code directExecutor}, a dangerous
- * choice in some cases. See the discussion in the {@link ListenableFuture#addListener
- * ListenableFuture.addListener} documentation. All its warnings about heavyweight listeners are
- * also applicable to heavyweight functions passed to this method.
- *
- * The returned {@code Future} attempts to keep its cancellation state in sync with that of the
- * input future. That is, if the returned {@code Future} is cancelled, it will attempt to cancel
- * the input, and if the input is cancelled, the returned {@code Future} will receive a callback
- * in which it will attempt to cancel itself.
- *
- * An example use of this method is to convert a serializable object returned from an RPC into
- * a POJO.
- *
- * @param input The future to transform
- * @param function A Function to transform the results of the provided future to the results of
- * the returned future. This will be run in the thread that notifies input it is complete.
- * @return A future that holds result of the transformation.
- * @since 9.0 (in 1.0 as {@code compose})
- * @deprecated Use {@linkplain #transform(ListenableFuture, Function, Executor) the overload that
- * requires an executor}. For identical behavior, pass {@link MoreExecutors#directExecutor},
- * but consider whether another executor would be safer, as discussed in the {@link
- * ListenableFuture#addListener ListenableFuture.addListener} documentation. This method is
- * scheduled to be removed in July 2018.
- */
- @Deprecated
- @com.google.errorprone.annotations.DoNotCall
- public static ListenableFuture More precisely, the returned {@code Future} takes its result from a {@code Future} produced
- * by applying the given {@code AsyncFunction} to the result of the original {@code Future}.
- * Example usage:
- *
- * This overload, which does not accept an executor, uses {@code directExecutor}, a dangerous
- * choice in some cases. See the discussion in the {@link ListenableFuture#addListener
- * ListenableFuture.addListener} documentation. All its warnings about heavyweight listeners are
- * also applicable to heavyweight functions passed to this method. (Specifically, {@code
- * directExecutor} functions should avoid heavyweight operations inside {@code
- * AsyncFunction.apply}. Any heavyweight operations should occur in other threads responsible for
- * completing the returned {@code Future}.)
- *
- * The returned {@code Future} attempts to keep its cancellation state in sync with that of the
- * input future and that of the future returned by the function. That is, if the returned {@code
- * Future} is cancelled, it will attempt to cancel the other two, and if either of the other two
- * is cancelled, the returned {@code Future} will receive a callback in which it will attempt to
- * cancel itself.
- *
- * @param input The future to transform
- * @param function A function to transform the result of the input future to the result of the
- * output future
- * @return A future that holds result of the function (if the input succeeded) or the original
- * input's failure (if not)
- * @since 19.0 (in 11.0 as {@code transform})
- * @deprecated Use {@linkplain #transformAsync(ListenableFuture, AsyncFunction, Executor) the
- * overload that requires an executor}. For identical behavior, pass {@link
- * MoreExecutors#directExecutor}, but consider whether another executor would be safer, as
- * discussed in the {@link ListenableFuture#addListener ListenableFuture.addListener}
- * documentation. This method is scheduled to be removed in July 2018.
- */
- @Deprecated
- @com.google.errorprone.annotations.DoNotCall
- public static ListenableFuture Usage example:
- *
- * This overload, which does not accept an executor, uses {@code directExecutor}, a dangerous
- * choice in some cases. See the discussion in the {@link ListenableFuture#addListener
- * ListenableFuture.addListener} documentation. All its warnings about heavyweight listeners are
- * also applicable to heavyweight functions passed to this method.
- *
- * @param input the primary input {@code Future}
- * @param exceptionType the exception type that triggers use of {@code fallback}. The exception
- * type is matched against the input's exception. "The input's exception" means the cause of
- * the {@link ExecutionException} thrown by {@code input.get()} or, if {@code get()} throws a
- * different kind of exception, that exception itself. To avoid hiding bugs and other
- * unrecoverable errors, callers should prefer more specific types, avoiding {@code
- * Throwable.class} in particular.
- * @param fallback the {@link Function} to be called if {@code input} fails with the expected
- * exception type. The function's argument is the input's exception. "The input's exception"
- * means the cause of the {@link ExecutionException} thrown by {@code input.get()} or, if
- * {@code get()} throws a different kind of exception, that exception itself.
- * @since 19.0
- * @deprecated Use {@linkplain #catching(ListenableFuture, Class, Function, Executor) the overload
- * that requires an executor}. For identical behavior, pass {@link
- * MoreExecutors#directExecutor}, but consider whether another executor would be safer, as
- * discussed in the {@link ListenableFuture#addListener ListenableFuture.addListener}
- * documentation. This method is scheduled to be removed in July 2018.
- */
- @Deprecated
- @com.google.errorprone.annotations.DoNotCall
- @Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
- public static Usage examples:
- *
- * The fallback can also choose to propagate the original exception when desired:
- *
- * This overload, which does not accept an executor, uses {@code directExecutor}, a dangerous
- * choice in some cases. See the discussion in the {@link ListenableFuture#addListener
- * ListenableFuture.addListener} documentation. All its warnings about heavyweight listeners are
- * also applicable to heavyweight functions passed to this method. (Specifically, {@code
- * directExecutor} functions should avoid heavyweight operations inside {@code
- * AsyncFunction.apply}. Any heavyweight operations should occur in other threads responsible for
- * completing the returned {@code Future}.)
- *
- * @param input the primary input {@code Future}
- * @param exceptionType the exception type that triggers use of {@code fallback}. The exception
- * type is matched against the input's exception. "The input's exception" means the cause of
- * the {@link ExecutionException} thrown by {@code input.get()} or, if {@code get()} throws a
- * different kind of exception, that exception itself. To avoid hiding bugs and other
- * unrecoverable errors, callers should prefer more specific types, avoiding {@code
- * Throwable.class} in particular.
- * @param fallback the {@link AsyncFunction} to be called if {@code input} fails with the expected
- * exception type. The function's argument is the input's exception. "The input's exception"
- * means the cause of the {@link ExecutionException} thrown by {@code input.get()} or, if
- * {@code get()} throws a different kind of exception, that exception itself.
- * @since 19.0 (similar functionality in 14.0 as {@code withFallback})
- * @deprecated Use {@linkplain #catchingAsync(ListenableFuture, Class, AsyncFunction, Executor)
- * the overload that requires an executor}. For identical behavior, pass {@link
- * MoreExecutors#directExecutor}, but consider whether another executor would be safer, as
- * discussed in the {@link ListenableFuture#addListener ListenableFuture.addListener}
- * documentation. This method is scheduled to be removed in July 2018.
- */
- @CanIgnoreReturnValue
- @Deprecated
- @com.google.errorprone.annotations.DoNotCall
- @Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class")
- public static This is mainly for fixed thread pools. See {@link Executors#newFixedThreadPool(int)}.
- *
- * @param executor the executor to modify to make sure it exits when the application is finished
- * @param terminationTimeout how long to wait for the executor to finish before terminating the
- * JVM
- * @return an unmodifiable version of the input which will not hang the JVM
- * @since 28.0
- */
- @Beta
- @GwtIncompatible // TODO
- public static ExecutorService getExitingExecutorService(
- ThreadPoolExecutor executor, Duration terminationTimeout) {
- return getExitingExecutorService(
- executor, toNanosSaturated(terminationTimeout), TimeUnit.NANOSECONDS);
- }
-
- /**
- * Converts the given ThreadPoolExecutor into an ExecutorService that exits when the application
- * is complete. It does so by using daemon threads and adding a shutdown hook to wait for their
- * completion.
- *
- * This is mainly for fixed thread pools. See {@link Executors#newFixedThreadPool(int)}.
- *
- * @param executor the executor to modify to make sure it exits when the application is finished
- * @param terminationTimeout how long to wait for the executor to finish before terminating the
- * JVM
- * @param timeUnit unit of time for the time parameter
- * @return an unmodifiable version of the input which will not hang the JVM
- */
- @Beta
- @GwtIncompatible // TODO
- @SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static ExecutorService getExitingExecutorService(
- ThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
- return new Application().getExitingExecutorService(executor, terminationTimeout, timeUnit);
- }
-
- /**
- * Converts the given ThreadPoolExecutor into an ExecutorService that exits when the application
- * is complete. It does so by using daemon threads and adding a shutdown hook to wait for their
- * completion.
- *
- * This method waits 120 seconds before continuing with JVM termination, even if the executor
- * has not finished its work.
- *
- * This is mainly for fixed thread pools. See {@link Executors#newFixedThreadPool(int)}.
- *
- * @param executor the executor to modify to make sure it exits when the application is finished
- * @return an unmodifiable version of the input which will not hang the JVM
- */
- @Beta
- @GwtIncompatible // concurrency
- public static ExecutorService getExitingExecutorService(ThreadPoolExecutor executor) {
- return new Application().getExitingExecutorService(executor);
- }
-
- /**
- * Converts the given ScheduledThreadPoolExecutor into a ScheduledExecutorService that exits when
- * the application is complete. It does so by using daemon threads and adding a shutdown hook to
- * wait for their completion.
- *
- * This is mainly for fixed thread pools. See {@link Executors#newScheduledThreadPool(int)}.
- *
- * @param executor the executor to modify to make sure it exits when the application is finished
- * @param terminationTimeout how long to wait for the executor to finish before terminating the
- * JVM
- * @return an unmodifiable version of the input which will not hang the JVM
- * @since 28.0
- */
- @Beta
- @GwtIncompatible // java.time.Duration
- public static ScheduledExecutorService getExitingScheduledExecutorService(
- ScheduledThreadPoolExecutor executor, Duration terminationTimeout) {
- return getExitingScheduledExecutorService(
- executor, toNanosSaturated(terminationTimeout), TimeUnit.NANOSECONDS);
- }
-
- /**
- * Converts the given ScheduledThreadPoolExecutor into a ScheduledExecutorService that exits when
- * the application is complete. It does so by using daemon threads and adding a shutdown hook to
- * wait for their completion.
- *
- * This is mainly for fixed thread pools. See {@link Executors#newScheduledThreadPool(int)}.
- *
- * @param executor the executor to modify to make sure it exits when the application is finished
- * @param terminationTimeout how long to wait for the executor to finish before terminating the
- * JVM
- * @param timeUnit unit of time for the time parameter
- * @return an unmodifiable version of the input which will not hang the JVM
- */
- @Beta
- @GwtIncompatible // TODO
- @SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static ScheduledExecutorService getExitingScheduledExecutorService(
- ScheduledThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
- return new Application()
- .getExitingScheduledExecutorService(executor, terminationTimeout, timeUnit);
- }
-
- /**
- * Converts the given ScheduledThreadPoolExecutor into a ScheduledExecutorService that exits when
- * the application is complete. It does so by using daemon threads and adding a shutdown hook to
- * wait for their completion.
- *
- * This method waits 120 seconds before continuing with JVM termination, even if the executor
- * has not finished its work.
- *
- * This is mainly for fixed thread pools. See {@link Executors#newScheduledThreadPool(int)}.
- *
- * @param executor the executor to modify to make sure it exits when the application is finished
- * @return an unmodifiable version of the input which will not hang the JVM
- */
- @Beta
- @GwtIncompatible // TODO
- public static ScheduledExecutorService getExitingScheduledExecutorService(
- ScheduledThreadPoolExecutor executor) {
- return new Application().getExitingScheduledExecutorService(executor);
- }
-
- /**
- * Add a shutdown hook to wait for thread completion in the given {@link ExecutorService service}.
- * This is useful if the given service uses daemon threads, and we want to keep the JVM from
- * exiting immediately on shutdown, instead giving these daemon threads a chance to terminate
- * normally.
- *
- * @param service ExecutorService which uses daemon threads
- * @param terminationTimeout how long to wait for the executor to finish before terminating the
- * JVM
- * @since 28.0
- */
- @Beta
- @GwtIncompatible // java.time.Duration
- public static void addDelayedShutdownHook(ExecutorService service, Duration terminationTimeout) {
- addDelayedShutdownHook(service, toNanosSaturated(terminationTimeout), TimeUnit.NANOSECONDS);
- }
-
- /**
- * Add a shutdown hook to wait for thread completion in the given {@link ExecutorService service}.
- * This is useful if the given service uses daemon threads, and we want to keep the JVM from
- * exiting immediately on shutdown, instead giving these daemon threads a chance to terminate
- * normally.
- *
- * @param service ExecutorService which uses daemon threads
- * @param terminationTimeout how long to wait for the executor to finish before terminating the
- * JVM
- * @param timeUnit unit of time for the time parameter
- */
- @Beta
- @GwtIncompatible // TODO
- @SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static void addDelayedShutdownHook(
- ExecutorService service, long terminationTimeout, TimeUnit timeUnit) {
- new Application().addDelayedShutdownHook(service, terminationTimeout, timeUnit);
- }
-
- /** Represents the current application to register shutdown hooks. */
- @GwtIncompatible // TODO
- @VisibleForTesting
- static class Application {
-
- final ExecutorService getExitingExecutorService(
- ThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
- useDaemonThreadFactory(executor);
- ExecutorService service = Executors.unconfigurableExecutorService(executor);
- addDelayedShutdownHook(executor, terminationTimeout, timeUnit);
- return service;
- }
-
- final ExecutorService getExitingExecutorService(ThreadPoolExecutor executor) {
- return getExitingExecutorService(executor, 120, TimeUnit.SECONDS);
- }
-
- final ScheduledExecutorService getExitingScheduledExecutorService(
- ScheduledThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
- useDaemonThreadFactory(executor);
- ScheduledExecutorService service = Executors.unconfigurableScheduledExecutorService(executor);
- addDelayedShutdownHook(executor, terminationTimeout, timeUnit);
- return service;
- }
-
- final ScheduledExecutorService getExitingScheduledExecutorService(
- ScheduledThreadPoolExecutor executor) {
- return getExitingScheduledExecutorService(executor, 120, TimeUnit.SECONDS);
- }
-
- final void addDelayedShutdownHook(
- final ExecutorService service, final long terminationTimeout, final TimeUnit timeUnit) {
- checkNotNull(service);
- checkNotNull(timeUnit);
- addShutdownHook(
- MoreExecutors.newThread(
- "DelayedShutdownHook-for-" + service,
- new Runnable() {
- @Override
- public void run() {
- try {
- // We'd like to log progress and failures that may arise in the
- // following code, but unfortunately the behavior of logging
- // is undefined in shutdown hooks.
- // This is because the logging code installs a shutdown hook of its
- // own. See Cleaner class inside {@link LogManager}.
- service.shutdown();
- service.awaitTermination(terminationTimeout, timeUnit);
- } catch (InterruptedException ignored) {
- // We're shutting down anyway, so just ignore.
- }
- }
- }));
- }
-
- @VisibleForTesting
- void addShutdownHook(Thread hook) {
- Runtime.getRuntime().addShutdownHook(hook);
- }
- }
-
- @GwtIncompatible // TODO
- private static void useDaemonThreadFactory(ThreadPoolExecutor executor) {
- executor.setThreadFactory(
- new ThreadFactoryBuilder()
- .setDaemon(true)
- .setThreadFactory(executor.getThreadFactory())
- .build());
- }
-
- // See newDirectExecutorService javadoc for behavioral notes.
- @GwtIncompatible // TODO
- private static final class DirectExecutorService extends AbstractListeningExecutorService {
- /** Lock used whenever accessing the state variables (runningTasks, shutdown) of the executor */
- private final Object lock = new Object();
-
- /*
- * Conceptually, these two variables describe the executor being in
- * one of three states:
- * - Active: shutdown == false
- * - Shutdown: runningTasks > 0 and shutdown == true
- * - Terminated: runningTasks == 0 and shutdown == true
- */
- @GuardedBy("lock")
- private int runningTasks = 0;
-
- @GuardedBy("lock")
- private boolean shutdown = false;
-
- @Override
- public void execute(Runnable command) {
- startTask();
- try {
- command.run();
- } finally {
- endTask();
- }
- }
-
- @Override
- public boolean isShutdown() {
- synchronized (lock) {
- return shutdown;
- }
- }
-
- @Override
- public void shutdown() {
- synchronized (lock) {
- shutdown = true;
- if (runningTasks == 0) {
- lock.notifyAll();
- }
- }
- }
-
- // See newDirectExecutorService javadoc for unusual behavior of this method.
- @Override
- public List Although all tasks are immediately executed in the thread that submitted the task, this
- * {@code ExecutorService} imposes a small locking overhead on each task submission in order to
- * implement shutdown and termination behavior.
- *
- * The implementation deviates from the {@code ExecutorService} specification with regards to
- * the {@code shutdownNow} method. First, "best-effort" with regards to canceling running tasks is
- * implemented as "no-effort". No interrupts or other attempts are made to stop threads executing
- * tasks. Second, the returned list will always be empty, as any submitted task is considered to
- * have started execution. This applies also to tasks given to {@code invokeAll} or {@code
- * invokeAny} which are pending serial execution, even the subset of the tasks that have not yet
- * started execution. It is unclear from the {@code ExecutorService} specification if these should
- * be included, and it's much easier to implement the interpretation that they not be. Finally, a
- * call to {@code shutdown} or {@code shutdownNow} may result in concurrent calls to {@code
- * invokeAll/invokeAny} throwing RejectedExecutionException, although a subset of the tasks may
- * already have been executed.
- *
- * @since 18.0 (present as MoreExecutors.sameThreadExecutor() since 10.0)
- */
- @GwtIncompatible // TODO
- public static ListeningExecutorService newDirectExecutorService() {
- return new DirectExecutorService();
- }
-
- /**
- * Returns an {@link Executor} that runs each task in the thread that invokes {@link
- * Executor#execute execute}, as in {@code ThreadPoolExecutor.CallerRunsPolicy}.
- *
- * This executor is appropriate for tasks that are lightweight and not deeply chained.
- * Inappropriate {@code directExecutor} usage can cause problems, and these problems can be
- * difficult to reproduce because they depend on timing. For example:
- *
- * This instance is equivalent to:
- *
- * This should be preferred to {@link #newDirectExecutorService()} because implementing the
- * {@link ExecutorService} subinterface necessitates significant performance overhead.
- *
- * @since 18.0
- */
- public static Executor directExecutor() {
- return DirectExecutor.INSTANCE;
- }
-
- /**
- * Returns an {@link Executor} that runs each task executed sequentially, such that no two tasks
- * are running concurrently. Submitted tasks have a happens-before order as defined in the Java
- * Language Specification.
- *
- * The executor uses {@code delegate} in order to {@link Executor#execute execute} each task in
- * turn, and does not create any threads of its own.
- *
- * After execution begins on a thread from the {@code delegate} {@link Executor}, tasks are
- * polled and executed from a task queue until there are no more tasks. The thread will not be
- * released until there are no more tasks to run.
- *
- * If a task is submitted while a thread is executing tasks from the task queue, the thread
- * will not be released until that submitted task is also complete.
- *
- * If a task is {@linkplain Thread#interrupt interrupted} while a task is running:
- *
- * {@code RuntimeException}s thrown by tasks are simply logged and the executor keeps trucking.
- * If an {@code Error} is thrown, the error will propagate and execution will stop until the next
- * time a task is submitted.
- *
- * When an {@code Error} is thrown by an executed task, previously submitted tasks may never
- * run. An attempt will be made to restart execution on the next call to {@code execute}. If the
- * {@code delegate} has begun to reject execution, the previously submitted tasks may never run,
- * despite not throwing a RejectedExecutionException synchronously with the call to {@code
- * execute}. If this behaviour is problematic, use an Executor with a single thread (e.g. {@link
- * Executors#newSingleThreadExecutor}).
- *
- * @since 23.3 (since 23.1 as {@code sequentialExecutor})
- */
- @Beta
- @GwtIncompatible
- public static Executor newSequentialExecutor(Executor delegate) {
- return new SequentialExecutor(delegate);
- }
-
- /**
- * Creates an {@link ExecutorService} whose {@code submit} and {@code invokeAll} methods submit
- * {@link ListenableFutureTask} instances to the given delegate executor. Those methods, as well
- * as {@code execute} and {@code invokeAny}, are implemented in terms of calls to {@code
- * delegate.execute}. All other methods are forwarded unchanged to the delegate. This implies that
- * the returned {@code ListeningExecutorService} never calls the delegate's {@code submit}, {@code
- * invokeAll}, and {@code invokeAny} methods, so any special handling of tasks must be implemented
- * in the delegate's {@code execute} method or by wrapping the returned {@code
- * ListeningExecutorService}.
- *
- * If the delegate executor was already an instance of {@code ListeningExecutorService}, it is
- * returned untouched, and the rest of this documentation does not apply.
- *
- * @since 10.0
- */
- @GwtIncompatible // TODO
- public static ListeningExecutorService listeningDecorator(ExecutorService delegate) {
- return (delegate instanceof ListeningExecutorService)
- ? (ListeningExecutorService) delegate
- : (delegate instanceof ScheduledExecutorService)
- ? new ScheduledListeningDecorator((ScheduledExecutorService) delegate)
- : new ListeningDecorator(delegate);
- }
-
- /**
- * Creates a {@link ScheduledExecutorService} whose {@code submit} and {@code invokeAll} methods
- * submit {@link ListenableFutureTask} instances to the given delegate executor. Those methods, as
- * well as {@code execute} and {@code invokeAny}, are implemented in terms of calls to {@code
- * delegate.execute}. All other methods are forwarded unchanged to the delegate. This implies that
- * the returned {@code ListeningScheduledExecutorService} never calls the delegate's {@code
- * submit}, {@code invokeAll}, and {@code invokeAny} methods, so any special handling of tasks
- * must be implemented in the delegate's {@code execute} method or by wrapping the returned {@code
- * ListeningScheduledExecutorService}.
- *
- * If the delegate executor was already an instance of {@code
- * ListeningScheduledExecutorService}, it is returned untouched, and the rest of this
- * documentation does not apply.
- *
- * @since 10.0
- */
- @GwtIncompatible // TODO
- public static ListeningScheduledExecutorService listeningDecorator(
- ScheduledExecutorService delegate) {
- return (delegate instanceof ListeningScheduledExecutorService)
- ? (ListeningScheduledExecutorService) delegate
- : new ScheduledListeningDecorator(delegate);
- }
-
- @GwtIncompatible // TODO
- private static class ListeningDecorator extends AbstractListeningExecutorService {
- private final ExecutorService delegate;
-
- ListeningDecorator(ExecutorService delegate) {
- this.delegate = checkNotNull(delegate);
- }
-
- @Override
- public final boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
- return delegate.awaitTermination(timeout, unit);
- }
-
- @Override
- public final boolean isShutdown() {
- return delegate.isShutdown();
- }
-
- @Override
- public final boolean isTerminated() {
- return delegate.isTerminated();
- }
-
- @Override
- public final void shutdown() {
- delegate.shutdown();
- }
-
- @Override
- public final List When running on AppEngine with access to AppEngine legacy
- * APIs, this method returns {@code ThreadManager.currentRequestThreadFactory()}. Otherwise,
- * it returns {@link Executors#defaultThreadFactory()}.
- *
- * @since 14.0
- */
- @Beta
- @GwtIncompatible // concurrency
- public static ThreadFactory platformThreadFactory() {
- if (!isAppEngineWithApiClasses()) {
- return Executors.defaultThreadFactory();
- }
- try {
- return (ThreadFactory)
- Class.forName("com.google.appengine.api.ThreadManager")
- .getMethod("currentRequestThreadFactory")
- .invoke(null);
- /*
- * Do not merge the 3 catch blocks below. javac would infer a type of
- * ReflectiveOperationException, which Animal Sniffer would reject. (Old versions of Android
- * don't *seem* to mind, but there might be edge cases of which we're unaware.)
- */
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Couldn't invoke ThreadManager.currentRequestThreadFactory", e);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Couldn't invoke ThreadManager.currentRequestThreadFactory", e);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException("Couldn't invoke ThreadManager.currentRequestThreadFactory", e);
- } catch (InvocationTargetException e) {
- throw Throwables.propagate(e.getCause());
- }
- }
-
- @GwtIncompatible // TODO
- private static boolean isAppEngineWithApiClasses() {
- if (System.getProperty("com.google.appengine.runtime.environment") == null) {
- return false;
- }
- try {
- Class.forName("com.google.appengine.api.utils.SystemProperty");
- } catch (ClassNotFoundException e) {
- return false;
- }
- try {
- // If the current environment is null, we're not inside AppEngine.
- return Class.forName("com.google.apphosting.api.ApiProxy")
- .getMethod("getCurrentEnvironment")
- .invoke(null)
- != null;
- } catch (ClassNotFoundException e) {
- // If ApiProxy doesn't exist, we're not on AppEngine at all.
- return false;
- } catch (InvocationTargetException e) {
- // If ApiProxy throws an exception, we're not in a proper AppEngine environment.
- return false;
- } catch (IllegalAccessException e) {
- // If the method isn't accessible, we're not on a supported version of AppEngine;
- return false;
- } catch (NoSuchMethodException e) {
- // If the method doesn't exist, we're not on a supported version of AppEngine;
- return false;
- }
- }
-
- /**
- * Creates a thread using {@link #platformThreadFactory}, and sets its name to {@code name} unless
- * changing the name is forbidden by the security manager.
- */
- @GwtIncompatible // concurrency
- static Thread newThread(String name, Runnable runnable) {
- checkNotNull(name);
- checkNotNull(runnable);
- Thread result = platformThreadFactory().newThread(runnable);
- try {
- result.setName(name);
- } catch (SecurityException e) {
- // OK if we can't set the name in this environment.
- }
- return result;
- }
-
- // TODO(lukes): provide overloads for ListeningExecutorService? ListeningScheduledExecutorService?
- // TODO(lukes): provide overloads that take constant strings? Function The names are retrieved from the {@code nameSupplier} on the thread that is being renamed
- * right before each task is run. The renaming is best effort, if a {@link SecurityManager}
- * prevents the renaming then it will be skipped but the tasks will still execute.
- *
- * @param executor The executor to decorate
- * @param nameSupplier The source of names for each task
- */
- @GwtIncompatible // concurrency
- static Executor renamingDecorator(final Executor executor, final Supplier The names are retrieved from the {@code nameSupplier} on the thread that is being renamed
- * right before each task is run. The renaming is best effort, if a {@link SecurityManager}
- * prevents the renaming then it will be skipped but the tasks will still execute.
- *
- * @param service The executor to decorate
- * @param nameSupplier The source of names for each task
- */
- @GwtIncompatible // concurrency
- static ExecutorService renamingDecorator(
- final ExecutorService service, final Supplier The names are retrieved from the {@code nameSupplier} on the thread that is being renamed
- * right before each task is run. The renaming is best effort, if a {@link SecurityManager}
- * prevents the renaming then it will be skipped but the tasks will still execute.
- *
- * @param service The executor to decorate
- * @param nameSupplier The source of names for each task
- */
- @GwtIncompatible // concurrency
- static ScheduledExecutorService renamingDecorator(
- final ScheduledExecutorService service, final Supplier The method takes the following steps:
- *
- * If, at any step of the process, the calling thread is interrupted, the method calls {@link
- * ExecutorService#shutdownNow()} and returns.
- *
- * @param service the {@code ExecutorService} to shut down
- * @param timeout the maximum time to wait for the {@code ExecutorService} to terminate
- * @return {@code true} if the {@code ExecutorService} was terminated successfully, {@code false}
- * if the call timed out or was interrupted
- * @since 28.0
- */
- @Beta
- @CanIgnoreReturnValue
- @GwtIncompatible // java.time.Duration
- public static boolean shutdownAndAwaitTermination(ExecutorService service, Duration timeout) {
- return shutdownAndAwaitTermination(service, toNanosSaturated(timeout), TimeUnit.NANOSECONDS);
- }
-
- /**
- * Shuts down the given executor service gradually, first disabling new submissions and later, if
- * necessary, cancelling remaining tasks.
- *
- * The method takes the following steps:
- *
- * If, at any step of the process, the calling thread is interrupted, the method calls {@link
- * ExecutorService#shutdownNow()} and returns.
- *
- * @param service the {@code ExecutorService} to shut down
- * @param timeout the maximum time to wait for the {@code ExecutorService} to terminate
- * @param unit the time unit of the timeout argument
- * @return {@code true} if the {@code ExecutorService} was terminated successfully, {@code false}
- * if the call timed out or was interrupted
- * @since 17.0
- */
- @Beta
- @CanIgnoreReturnValue
- @GwtIncompatible // concurrency
- @SuppressWarnings("GoodTime") // should accept a java.time.Duration
- public static boolean shutdownAndAwaitTermination(
- ExecutorService service, long timeout, TimeUnit unit) {
- long halfTimeoutNanos = unit.toNanos(timeout) / 2;
- // Disable new tasks from being submitted
- service.shutdown();
- try {
- // Wait for half the duration of the timeout for existing tasks to terminate
- if (!service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS)) {
- // Cancel currently executing tasks
- service.shutdownNow();
- // Wait the other half of the timeout for tasks to respond to being cancelled
- service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS);
- }
- } catch (InterruptedException ie) {
- // Preserve interrupt status
- Thread.currentThread().interrupt();
- // (Re-)Cancel if current thread also interrupted
- service.shutdownNow();
- }
- return service.isTerminated();
- }
-
- /**
- * Returns an Executor that will propagate {@link RejectedExecutionException} from the delegate
- * executor to the given {@code future}.
- *
- * Note, the returned executor can only be used once.
- */
- static Executor rejectionPropagatingExecutor(
- final Executor delegate, final AbstractFuture> future) {
- checkNotNull(delegate);
- checkNotNull(future);
- if (delegate == directExecutor()) {
- // directExecutor() cannot throw RejectedExecutionException
- return delegate;
- }
- return new Executor() {
- @Override
- public void execute(Runnable command) {
- try {
- delegate.execute(command);
- } catch (RejectedExecutionException e) {
- future.setException(e);
- }
- }
- };
- }
-
- // Nacho start
- /**
- * Creates an executor service that runs each task in the thread that invokes {@code
- * execute/submit}, as in {@code ThreadPoolExecutor.CallerRunsPolicy}. This applies both to
- * individually submitted tasks and to collections of tasks submitted via {@code invokeAll} or
- * {@code invokeAny}. In the latter case, tasks will run serially on the calling thread. Tasks are
- * run to completion before a {@code Future} is returned to the caller (unless the executor has
- * been shutdown).
- *
- * Although all tasks are immediately executed in the thread that submitted the task, this
- * {@code ExecutorService} imposes a small locking overhead on each task submission in order to
- * implement shutdown and termination behavior.
- *
- * The implementation deviates from the {@code ExecutorService} specification with regards to
- * the {@code shutdownNow} method. First, "best-effort" with regards to canceling running tasks is
- * implemented as "no-effort". No interrupts or other attempts are made to stop threads executing
- * tasks. Second, the returned list will always be empty, as any submitted task is considered to
- * have started execution. This applies also to tasks given to {@code invokeAll} or {@code
- * invokeAny} which are pending serial execution, even the subset of the tasks that have not yet
- * started execution. It is unclear from the {@code ExecutorService} specification if these should
- * be included, and it's much easier to implement the interpretation that they not be. Finally, a
- * call to {@code shutdown} or {@code shutdownNow} may result in concurrent calls to {@code
- * invokeAll/invokeAny} throwing RejectedExecutionException, although a subset of the tasks may
- * already have been executed.
- *
- * @since 10.0
- * @deprecated replaced by {@link MoreExecutors#sameThreadExecutor()}
- * @see MoreExecutors#sameThreadExecutor()
- */
- @Deprecated
- @GwtIncompatible
- public static ListeningExecutorService sameThreadExecutor() {
- return newDirectExecutorService();
- }
- // Nacho end
-}
\ No newline at end of file
diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/AchievementCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/AchievementCommand.java
deleted file mode 100644
index c2e179505..000000000
--- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/AchievementCommand.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package org.bukkit.command.defaults;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.commons.lang.Validate;
-import org.bukkit.Achievement;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Statistic;
-import org.bukkit.Material;
-import org.bukkit.Statistic.Type;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Player;
-import org.bukkit.event.player.PlayerAchievementAwardedEvent;
-import org.bukkit.event.player.PlayerStatisticIncrementEvent;
-
-import com.google.common.collect.ImmutableList;
-
-@Deprecated
-public class AchievementCommand extends VanillaCommand {
- public AchievementCommand() {
- super("achievement");
- this.description = "Gives the specified player an achievement or changes a statistic value. Use '*' to give all achievements.";
- this.usageMessage = "/achievement give
- *
- *
- * {@code
- * ListenableFuture
- *
- * {@code
- * ListenableFuture
- *
- * {@code
- * ListenableFuture
- *
- * {@code
- * ListenableFuture
- *
- * {@code
- * ListenableFuture
- *
- * > rowsFuture =
- * transform(queryFuture, QueryResult::getRows, executor);
- * }
> allAsList(
- ListenableFuture extends V>... futures) {
- ListenableFuture
> nullable =
- new ListFuture
> nonNull = nullable;
- return nonNull;
- }
-
- /**
- * Creates a new {@code ListenableFuture} whose value is a list containing the values of all its
- * input futures, if all succeed.
- *
- *
> allAsList(
- Iterable extends ListenableFuture extends V>> futures) {
- ListenableFuture
> nullable =
- new ListFuture
> nonNull = nullable;
- return nonNull;
- }
-
- /**
- * Creates a {@link FutureCombiner} that processes the completed futures whether or not they're
- * successful.
- *
- *
{@code
- * final ListenableFuture
- *
- * @since 20.0
- */
- @Beta
- @CanIgnoreReturnValue // TODO(cpovirk): Consider removing, especially if we provide run(Runnable)
- @GwtCompatible
- public static final class FutureCombiner> recentCommandsFuture =
- * recentCommandsService.findRecentCommands(username);
- * ListenableFuture
> successfulAsList(
- ListenableFuture extends V>... futures) {
- /*
- * Another way to express this signature would be to bound
> successfulAsList(
- Iterable extends ListenableFuture extends V>> futures) {
- return new ListFuture
{@code
- * ListenableFuture
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * {@code
- * ListenableFuture
- *
- * {@code
- * ListenableFuture
- *
- * > rowsFuture =
- * transform(queryFuture, QueryResult::getRows);
- * }
{@code
- * ListenableFuture
- *
- * {@code
- * ListenableFuture
- *
- * {@code
- * ListenableFuture
- *
- * {@code
- * ListenableFuture
- *
- *
- *
- *
- * Additionally, beware of executing tasks with {@code directExecutor} while holding a lock. Since
- * the task you submit to the executor (or any other arbitrary work the executor does) may do slow
- * work or acquire other locks, you risk deadlocks.
- *
- * {@code
- * final class DirectExecutor implements Executor {
- * public void execute(Runnable r) {
- * r.run();
- * }
- * }
- * }
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *