Skip to content

Commit

Permalink
Remove some methods that are scheduled for removal in 23.0, along wit…
Browse files Browse the repository at this point in the history
…h one that was apparently scheduled for removal in 21.0.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162962688
  • Loading branch information
cgdecker committed Jul 24, 2017
1 parent 22da091 commit 6dae21f
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 300 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public void testFromArrayAndIteratorRemove() {
}
}

public void testOfArrayAndIteratorRemove() {
FluentIterable<TimeUnit> units = FluentIterable.of(TimeUnit.values());
assertTrue(Iterables.removeIf(units, Predicates.equalTo(TimeUnit.SECONDS)));
}

public void testFrom() {
assertEquals(ImmutableList.of(1, 2, 3, 4),
Lists.newArrayList(FluentIterable.from(ImmutableList.of(1, 2, 3, 4))));
Expand All @@ -91,11 +86,6 @@ public void testOf() {
Lists.newArrayList(FluentIterable.of(1, 2, 3, 4)));
}

public void testOfArray() {
assertEquals(ImmutableList.of("1", "2", "3", "4"),
Lists.newArrayList(FluentIterable.of(new Object[] {"1", "2", "3", "4"})));
}

public void testFromArray() {
assertEquals(ImmutableList.of("1", "2", "3", "4"),
Lists.newArrayList(FluentIterable.from(new Object[] {"1", "2", "3", "4"})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,55 +150,6 @@ public void testNewProxy_badMethodWithNotEnoughTime() throws Exception {
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
}

@Deprecated
public void testOldCallWithTimeout_goodCallableWithEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();

String result =
service.callWithTimeout(GOOD_CALLABLE, ENOUGH_MS, MILLISECONDS, true /* interruptible */);

assertThat(result).isEqualTo(GOOD_CALLABLE_RESULT);
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
}

@Deprecated
public void testOldCallWithTimeout_goodCallableWithNotEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();

try {
service.callWithTimeout(
GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS, false /* interruptible */);
fail("no exception thrown");
} catch (UncheckedTimeoutException expected) {
}

assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
}

@Deprecated
public void testOldCallWithTimeout_badCallableWithEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();
try {
service.callWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS, false /* interruptible */);
fail("no exception thrown");
} catch (SampleException expected) {
}
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
}

@Deprecated
public void testOldCallWithTimeout_badCallableWithNotEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();

try {
service.callWithTimeout(BAD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS, true /* interruptible */);
fail("no exception thrown");
} catch (UncheckedTimeoutException expected) {
}

assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
}

public void testCallWithTimeout_goodCallableWithEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();

Expand Down
18 changes: 0 additions & 18 deletions android/guava/src/com/google/common/collect/FluentIterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,24 +314,6 @@ public static <E> FluentIterable<E> of() {
return FluentIterable.from(ImmutableList.<E>of());
}

/**
* Returns a fluent iterable containing {@code elements} in the specified order.
*
* <p>The returned iterable is modifiable, but modifications do not affect the input array.
*
* <p><b>{@code Stream} equivalent:</b> {@link java.util.stream.Stream#of(Object[])
* Stream.of(T...)}.
*
* @deprecated Use {@link #from(Object[])} instead (but note the differences in mutability). This
* method will be removed in Guava release 21.0.
* @since 18.0
*/
@Beta
@Deprecated
public static <E> FluentIterable<E> of(E[] elements) {
return from(Lists.newArrayList(elements));
}

/**
* Returns a fluent iterable containing the specified elements in order.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ public <T> T newProxy(
return target; // ha ha
}

@Deprecated
@Override
public <T> T callWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)
throws Exception {
checkNotNull(timeoutUnit);
return callable.call(); // fooled you
}

@Override
public <T> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws ExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ObjectArrays;
import com.google.common.collect.Sets;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -49,40 +48,11 @@ public final class SimpleTimeLimiter implements TimeLimiter {

private final ExecutorService executor;

/**
* Constructs a TimeLimiter instance using the given executor service to execute proxied method
* calls.
*
* <p><b>Warning:</b> using a bounded executor may be counterproductive! If the thread pool fills
* up, any time callers spend waiting for a thread may count toward their time limit, and in this
* case the call may even time out before the target method is ever invoked.
*
* @param executor the ExecutorService that will execute the method calls on the target objects;
* for example, a {@link Executors#newCachedThreadPool()}.
* @deprecated Use {@link #create(ExecutorService)} instead. This method is scheduled to be
* removed in Guava 23.0.
*/
@Deprecated
public SimpleTimeLimiter(ExecutorService executor) {
private
SimpleTimeLimiter(ExecutorService executor) {
this.executor = checkNotNull(executor);
}

/**
* Constructs a TimeLimiter instance using a {@link Executors#newCachedThreadPool()} to execute
* proxied method calls.
*
* <p><b>Warning:</b> using a bounded executor may be counterproductive! If the thread pool fills
* up, any time callers spend waiting for a thread may count toward their time limit, and in this
* case the call may even time out before the target method is ever invoked.
*
* @deprecated Use {@link #create(ExecutorService)} instead with {@code
* Executors.newCachedThreadPool()}. This method is scheduled to be removed in Guava 23.0.
*/
@Deprecated
public SimpleTimeLimiter() {
this(Executors.newCachedThreadPool());
}

/**
* Creates a TimeLimiter instance using the given executor service to execute method calls.
*
Expand Down Expand Up @@ -135,11 +105,8 @@ public Object call() throws Exception {
return newProxy(interfaceType, handler);
}

// TODO: should this actually throw only ExecutionException?
@Deprecated
@CanIgnoreReturnValue
@Override
public <T> T callWithTimeout(
private
<T> T callWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)
throws Exception {
checkNotNull(callable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.google.common.annotations.Beta;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -76,32 +75,6 @@ public interface TimeLimiter {
*/
<T> T newProxy(T target, Class<T> interfaceType, long timeoutDuration, TimeUnit timeoutUnit);

/**
* Invokes a specified Callable, timing out after the specified time limit. If the target method
* call finished before the limit is reached, the return value or exception is propagated to the
* caller exactly as-is. If, on the other hand, the time limit is reached, we attempt to abort the
* call to the target, and throw an {@link UncheckedTimeoutException} to the caller.
*
* @param callable the Callable to execute
* @param timeoutDuration with timeoutUnit, the maximum length of time to wait
* @param timeoutUnit with timeoutDuration, the maximum length of time to wait
* @param interruptible whether to respond to thread interruption by aborting the operation and
* throwing InterruptedException; if false, the operation is allowed to complete or time out,
* and the current thread's interrupt status is re-asserted.
* @return the result returned by the Callable
* @throws InterruptedException if {@code interruptible} is true and our thread is interrupted
* during execution
* @throws UncheckedTimeoutException if the time limit is reached
* @deprecated Use one of the other {@code call[Uninterruptibly]WithTimeout()} or {@code
* run[Uninterruptibly]WithTimeout()} methods. This method is scheduled to be removed in Guava
* 23.0.
*/
@Deprecated
@CanIgnoreReturnValue
<T> T callWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean interruptible)
throws Exception;

/**
* Invokes a specified Callable, timing out after the specified time limit. If the target method
* call finishes before the limit is reached, the return value or a wrapped exception is
Expand Down
10 changes: 0 additions & 10 deletions guava-tests/test/com/google/common/collect/FluentIterableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ public void testFromArrayAndIteratorRemove() {
}
}

public void testOfArrayAndIteratorRemove() {
FluentIterable<TimeUnit> units = FluentIterable.of(TimeUnit.values());
assertTrue(Iterables.removeIf(units, Predicates.equalTo(TimeUnit.SECONDS)));
}

public void testFrom() {
assertEquals(ImmutableList.of(1, 2, 3, 4),
Lists.newArrayList(FluentIterable.from(ImmutableList.of(1, 2, 3, 4))));
Expand All @@ -95,11 +90,6 @@ public void testOf() {
Lists.newArrayList(FluentIterable.of(1, 2, 3, 4)));
}

public void testOfArray() {
assertEquals(ImmutableList.of("1", "2", "3", "4"),
Lists.newArrayList(FluentIterable.of(new Object[] {"1", "2", "3", "4"})));
}

public void testFromArray() {
assertEquals(ImmutableList.of("1", "2", "3", "4"),
Lists.newArrayList(FluentIterable.from(new Object[] {"1", "2", "3", "4"})));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,55 +150,6 @@ public void testNewProxy_badMethodWithNotEnoughTime() throws Exception {
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
}

@Deprecated
public void testOldCallWithTimeout_goodCallableWithEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();

String result =
service.callWithTimeout(GOOD_CALLABLE, ENOUGH_MS, MILLISECONDS, true /* interruptible */);

assertThat(result).isEqualTo(GOOD_CALLABLE_RESULT);
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
}

@Deprecated
public void testOldCallWithTimeout_goodCallableWithNotEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();

try {
service.callWithTimeout(
GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS, false /* interruptible */);
fail("no exception thrown");
} catch (UncheckedTimeoutException expected) {
}

assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
}

@Deprecated
public void testOldCallWithTimeout_badCallableWithEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();
try {
service.callWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS, false /* interruptible */);
fail("no exception thrown");
} catch (SampleException expected) {
}
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
}

@Deprecated
public void testOldCallWithTimeout_badCallableWithNotEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();

try {
service.callWithTimeout(BAD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS, true /* interruptible */);
fail("no exception thrown");
} catch (UncheckedTimeoutException expected) {
}

assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
}

public void testCallWithTimeout_goodCallableWithEnoughTime() throws Exception {
Stopwatch stopwatch = Stopwatch.createStarted();

Expand Down
18 changes: 0 additions & 18 deletions guava/src/com/google/common/collect/FluentIterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,24 +311,6 @@ public static <E> FluentIterable<E> of() {
return FluentIterable.from(ImmutableList.<E>of());
}

/**
* Returns a fluent iterable containing {@code elements} in the specified order.
*
* <p>The returned iterable is modifiable, but modifications do not affect the input array.
*
* <p><b>{@code Stream} equivalent:</b> {@link java.util.stream.Stream#of(Object[])
* Stream.of(T...)}.
*
* @deprecated Use {@link #from(Object[])} instead (but note the differences in mutability). This
* method will be removed in Guava release 21.0.
* @since 18.0
*/
@Beta
@Deprecated
public static <E> FluentIterable<E> of(E[] elements) {
return from(Lists.newArrayList(elements));
}

/**
* Returns a fluent iterable containing the specified elements in order.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ public <T> T newProxy(
return target; // ha ha
}

@Deprecated
@Override
public <T> T callWithTimeout(
Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)
throws Exception {
checkNotNull(timeoutUnit);
return callable.call(); // fooled you
}

@Override
public <T> T callWithTimeout(Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit)
throws ExecutionException {
Expand Down

0 comments on commit 6dae21f

Please sign in to comment.