JCLOUDS-534: Address Guava 17 compatibility issues

Corrected with:

find -name \*.java | xargs sed -i 's/new Stopwatch();/Stopwatch.createUnstarted();/'
find -name \*.java | xargs sed -i 's/new Stopwatch().start();/Stopwatch.createStarted();/'
This commit is contained in:
Andrew Gaul 2014-04-11 14:04:46 -07:00
parent b5218e0ce6
commit 7af18d4843
6 changed files with 10 additions and 10 deletions

View File

@ -59,7 +59,7 @@ public class SQSErrorRetryHandlerTest {
HttpCommand command = createHttpCommandForFailureCount(59); HttpCommand command = createHttpCommandForFailureCount(59);
Stopwatch watch = new Stopwatch().start(); Stopwatch watch = Stopwatch.createStarted();
assertTrue(retry.shouldRetryRequestOnError(command, response, error)); assertTrue(retry.shouldRetryRequestOnError(command, response, error));
assertEquals(command.getFailureCount(), 60); assertEquals(command.getFailureCount(), 60);
// allow for slightly inaccurate system timers // allow for slightly inaccurate system timers
@ -75,7 +75,7 @@ public class SQSErrorRetryHandlerTest {
HttpCommand command = createHttpCommandForFailureCount(60); HttpCommand command = createHttpCommandForFailureCount(60);
Stopwatch watch = new Stopwatch().start(); Stopwatch watch = Stopwatch.createStarted();
assertFalse(retry.shouldRetryRequestOnError(command, response, error)); assertFalse(retry.shouldRetryRequestOnError(command, response, error));
assertEquals(command.getFailureCount(), 61); assertEquals(command.getFailureCount(), 61);
assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) < 100); assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) < 100);

View File

@ -62,7 +62,7 @@ public class PollNodeRunning implements Function<AtomicReference<NodeMetadata>,
String originalId = node.get().getId(); String originalId = node.get().getId();
NodeMetadata originalNode = node.get(); NodeMetadata originalNode = node.get();
try { try {
Stopwatch stopwatch = new Stopwatch().start(); Stopwatch stopwatch = Stopwatch.createStarted();
if (!nodeRunning.apply(node)) { if (!nodeRunning.apply(node)) {
long timeWaited = stopwatch.elapsed(TimeUnit.MILLISECONDS); long timeWaited = stopwatch.elapsed(TimeUnit.MILLISECONDS);
if (node.get() == null) { if (node.get() == null) {

View File

@ -656,7 +656,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
protected ServiceStats trackAvailabilityOfProcessOnNode(Statement process, String processName, NodeMetadata node) { protected ServiceStats trackAvailabilityOfProcessOnNode(Statement process, String processName, NodeMetadata node) {
ServiceStats stats = new ServiceStats(); ServiceStats stats = new ServiceStats();
Stopwatch watch = new Stopwatch().start(); Stopwatch watch = Stopwatch.createStarted();
ExecResponse exec = client.runScriptOnNode(node.getId(), process, runAsRoot(false).wrapInInitScript(false)); ExecResponse exec = client.runScriptOnNode(node.getId(), process, runAsRoot(false).wrapInInitScript(false));
stats.backgroundProcessMilliseconds = watch.elapsed(TimeUnit.MILLISECONDS); stats.backgroundProcessMilliseconds = watch.elapsed(TimeUnit.MILLISECONDS);
watch.reset().start(); watch.reset().start();
@ -697,7 +697,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("test", group); ImmutableMap<String, String> userMetadata = ImmutableMap.<String, String> of("test", group);
ImmutableSet<String> tags = ImmutableSet. of(group); ImmutableSet<String> tags = ImmutableSet. of(group);
Stopwatch watch = new Stopwatch().start(); Stopwatch watch = Stopwatch.createStarted();
NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1,
inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata).tags(tags))); inboundPorts(22, 8080).blockOnPort(22, 300).userMetadata(userMetadata).tags(tags)));
long createSeconds = watch.elapsed(TimeUnit.SECONDS); long createSeconds = watch.elapsed(TimeUnit.SECONDS);

View File

@ -102,7 +102,7 @@ public class ConcurrentOpenSocketFinderTest {
OpenSocketFinder finder = new ConcurrentOpenSocketFinder(socketAlwaysClosed, nodeRunning, userExecutor); OpenSocketFinder finder = new ConcurrentOpenSocketFinder(socketAlwaysClosed, nodeRunning, userExecutor);
Stopwatch stopwatch = new Stopwatch(); Stopwatch stopwatch = Stopwatch.createUnstarted();
stopwatch.start(); stopwatch.start();
try { try {
finder.findOpenSocketOnNode(node, 22, timeoutMs, MILLISECONDS); finder.findOpenSocketOnNode(node, 22, timeoutMs, MILLISECONDS);

View File

@ -123,7 +123,7 @@ public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest
public void testCacheIsFasterWhenNoAnnotationPresent() { public void testCacheIsFasterWhenNoAnnotationPresent() {
InvocationSuccess keyPairApi = getKeyPairApi(); InvocationSuccess keyPairApi = getKeyPairApi();
ImplicitOptionalConverter fn = forApiVersion("2011-07-15"); ImplicitOptionalConverter fn = forApiVersion("2011-07-15");
Stopwatch watch = new Stopwatch().start(); Stopwatch watch = Stopwatch.createStarted();
fn.apply(keyPairApi); fn.apply(keyPairApi);
long first = watch.stop().elapsed(TimeUnit.MICROSECONDS); long first = watch.stop().elapsed(TimeUnit.MICROSECONDS);
watch.reset().start(); watch.reset().start();
@ -137,7 +137,7 @@ public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest
public void testCacheIsFasterWhenAnnotationPresent() { public void testCacheIsFasterWhenAnnotationPresent() {
InvocationSuccess floatingIpApi = getKeyPairApi(); InvocationSuccess floatingIpApi = getKeyPairApi();
ImplicitOptionalConverter fn = forApiVersion("2011-07-15"); ImplicitOptionalConverter fn = forApiVersion("2011-07-15");
Stopwatch watch = new Stopwatch().start(); Stopwatch watch = Stopwatch.createStarted();
fn.apply(floatingIpApi); fn.apply(floatingIpApi);
long first = watch.stop().elapsed(TimeUnit.MICROSECONDS); long first = watch.stop().elapsed(TimeUnit.MICROSECONDS);
watch.reset().start(); watch.reset().start();

View File

@ -52,7 +52,7 @@ public class Predicates2Test {
@BeforeMethod @BeforeMethod
public void setUp() { public void setUp() {
stopwatch = new Stopwatch(); stopwatch = Stopwatch.createUnstarted();
} }
@Test @Test
@ -161,7 +161,7 @@ public class Predicates2Test {
RepeatedAttemptsPredicate(int succeedOnAttempt) { RepeatedAttemptsPredicate(int succeedOnAttempt) {
this.succeedOnAttempt = succeedOnAttempt; this.succeedOnAttempt = succeedOnAttempt;
this.stopwatch = new Stopwatch(); this.stopwatch = Stopwatch.createUnstarted();
stopwatch.start(); stopwatch.start();
} }
@Override @Override