Upgrade Guava to 20.0-rc1

The propagate and propagateIfPossible methods are deprecated. Replace
them with the recommended alternatives.

Change-Id: I9107dc51b968e2acc453502ece3c5ed5dd58b5de
This commit is contained in:
David Pursehouse
2016-10-24 21:41:57 +09:00
parent 5c7dbae701
commit ef6398e9d0
20 changed files with 31 additions and 25 deletions

View File

@@ -223,8 +223,8 @@ maven_jar(
maven_jar( maven_jar(
name = 'guava', name = 'guava',
artifact = 'com.google.guava:guava:19.0', artifact = 'com.google.guava:guava:20.0-rc1',
sha1 = '6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9', sha1 = '4c2a4581b69b16a57968da32fcadb8e362b639b2',
) )
maven_jar( maven_jar(

View File

@@ -399,7 +399,7 @@ public class LuceneChangeIndex implements ChangeIndex {
close(); close();
throw new OrmRuntimeException(e); throw new OrmRuntimeException(e);
} catch (ExecutionException e) { } catch (ExecutionException e) {
Throwables.propagateIfPossible(e.getCause()); Throwables.throwIfUnchecked(e.getCause());
throw new OrmRuntimeException(e.getCause()); throw new OrmRuntimeException(e.getCause());
} }
} }

View File

@@ -94,7 +94,7 @@ public class AccountLoader {
directory.fillAccountInfo( directory.fillAccountInfo(
Iterables.concat(created.values(), provided), options); Iterables.concat(created.values(), provided), options);
} catch (DirectoryException e) { } catch (DirectoryException e) {
Throwables.propagateIfPossible(e.getCause(), OrmException.class); Throwables.throwIfInstanceOf(e.getCause(), OrmException.class);
throw new OrmException(e); throw new OrmException(e);
} }
} }

View File

@@ -47,7 +47,7 @@ public class GetDetail implements RestReadView<AccountResource> {
directory.fillAccountInfo(Collections.singleton(info), directory.fillAccountInfo(Collections.singleton(info),
EnumSet.allOf(FillOptions.class)); EnumSet.allOf(FillOptions.class));
} catch (DirectoryException e) { } catch (DirectoryException e) {
Throwables.propagateIfPossible(e.getCause(), OrmException.class); Throwables.throwIfInstanceOf(e.getCause(), OrmException.class);
throw new OrmException(e); throw new OrmException(e);
} }
return info; return info;

View File

@@ -154,8 +154,8 @@ import javax.security.auth.login.LoginException;
} }
}); });
} catch (PrivilegedActionException e) { } catch (PrivilegedActionException e) {
Throwables.propagateIfPossible(e.getException(), NamingException.class); Throwables.throwIfInstanceOf(e.getException(), NamingException.class);
Throwables.propagateIfPossible(e.getException(), RuntimeException.class); Throwables.throwIfInstanceOf(e.getException(), RuntimeException.class);
LdapRealm.log.warn("Internal error", e.getException()); LdapRealm.log.warn("Internal error", e.getException());
return null; return null;
} finally { } finally {

View File

@@ -299,7 +299,7 @@ public class ChangeJson {
} catch (PatchListNotAvailableException | GpgException | OrmException } catch (PatchListNotAvailableException | GpgException | OrmException
| IOException | RuntimeException e) { | IOException | RuntimeException e) {
if (!has(CHECK)) { if (!has(CHECK)) {
Throwables.propagateIfPossible(e, OrmException.class); Throwables.throwIfInstanceOf(e, OrmException.class);
throw new OrmException(e); throw new OrmException(e);
} }
return checkOnly(cd); return checkOnly(cd);

View File

@@ -490,7 +490,7 @@ public class BatchUpdate implements AutoCloseable {
throw new ResourceNotFoundException(e.getMessage(), e); throw new ResourceNotFoundException(e.getMessage(), e);
} catch (Exception e) { } catch (Exception e) {
Throwables.propagateIfPossible(e); Throwables.throwIfUnchecked(e);
throw new UpdateException(e); throw new UpdateException(e);
} }
} }
@@ -693,7 +693,7 @@ public class BatchUpdate implements AutoCloseable {
logDebug("No objects to flush"); logDebug("No objects to flush");
} }
} catch (Exception e) { } catch (Exception e) {
Throwables.propagateIfPossible(e, RestApiException.class); Throwables.throwIfInstanceOf(e, RestApiException.class);
throw new UpdateException(e); throw new UpdateException(e);
} }
} }
@@ -778,8 +778,8 @@ public class BatchUpdate implements AutoCloseable {
} }
success = true; success = true;
} catch (ExecutionException | InterruptedException e) { } catch (ExecutionException | InterruptedException e) {
Throwables.propagateIfInstanceOf(e.getCause(), UpdateException.class); Throwables.throwIfInstanceOf(e.getCause(), UpdateException.class);
Throwables.propagateIfInstanceOf(e.getCause(), RestApiException.class); Throwables.throwIfInstanceOf(e.getCause(), RestApiException.class);
throw new UpdateException(e); throw new UpdateException(e);
} catch (OrmException | IOException e) { } catch (OrmException | IOException e) {
throw new UpdateException(e); throw new UpdateException(e);

View File

@@ -197,7 +197,9 @@ public class RepoSequence {
limit = counter + count; limit = counter + count;
acquireCount++; acquireCount++;
} catch (ExecutionException | RetryException e) { } catch (ExecutionException | RetryException e) {
Throwables.propagateIfInstanceOf(e.getCause(), OrmException.class); if (e.getCause() != null) {
Throwables.throwIfInstanceOf(e.getCause(), OrmException.class);
}
throw new OrmException(e); throw new OrmException(e);
} catch (IOException e) { } catch (IOException e) {
throw new OrmException(e); throw new OrmException(e);

View File

@@ -93,7 +93,7 @@ class IntraLineLoader implements Callable<IntraLineDiff> {
} catch (ExecutionException e) { } catch (ExecutionException e) {
// If there was an error computing the result, carry it // If there was an error computing the result, carry it
// up to the caller so the cache knows this key is invalid. // up to the caller so the cache knows this key is invalid.
Throwables.propagateIfInstanceOf(e.getCause(), Exception.class); Throwables.throwIfInstanceOf(e.getCause(), Exception.class);
throw new Exception(e.getMessage(), e.getCause()); throw new Exception(e.getMessage(), e.getCause());
} }
} }

View File

@@ -279,7 +279,7 @@ public class PatchListLoader implements Callable<PatchList> {
} catch (ExecutionException e) { } catch (ExecutionException e) {
// If there was an error computing the result, carry it // If there was an error computing the result, carry it
// up to the caller so the cache knows this key is invalid. // up to the caller so the cache knows this key is invalid.
Throwables.propagateIfInstanceOf(e.getCause(), IOException.class); Throwables.throwIfInstanceOf(e.getCause(), IOException.class);
throw new IOException(e.getMessage(), e.getCause()); throw new IOException(e.getMessage(), e.getCause());
} }
} }

View File

@@ -150,7 +150,7 @@ public class ProjectCacheImpl implements ProjectCache {
} catch (ExecutionException e) { } catch (ExecutionException e) {
if (!(e.getCause() instanceof RepositoryNotFoundException)) { if (!(e.getCause() instanceof RepositoryNotFoundException)) {
log.warn(String.format("Cannot read project %s", projectName.get()), e); log.warn(String.format("Cannot read project %s", projectName.get()), e);
Throwables.propagateIfInstanceOf(e.getCause(), IOException.class); Throwables.throwIfInstanceOf(e.getCause(), IOException.class);
throw new IOException(e); throw new IOException(e);
} }
return null; return null;

View File

@@ -49,7 +49,7 @@ public class RefPattern {
try { try {
return exampleCache.get(refPattern); return exampleCache.get(refPattern);
} catch (ExecutionException e) { } catch (ExecutionException e) {
Throwables.propagateIfPossible(e.getCause()); Throwables.throwIfUnchecked(e.getCause());
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} else if (refPattern.endsWith("/*")) { } else if (refPattern.endsWith("/*")) {

View File

@@ -83,7 +83,9 @@ public class AndSource<T> extends AndPredicate<T>
try { try {
return readImpl(); return readImpl();
} catch (OrmRuntimeException err) { } catch (OrmRuntimeException err) {
Throwables.propagateIfInstanceOf(err.getCause(), OrmException.class); if (err.getCause() != null) {
Throwables.throwIfInstanceOf(err.getCause(), OrmException.class);
}
throw new OrmException(err); throw new OrmException(err);
} }
} }

View File

@@ -136,7 +136,9 @@ public abstract class QueryProcessor<T> {
} catch (OrmRuntimeException e) { } catch (OrmRuntimeException e) {
throw new OrmException(e.getMessage(), e); throw new OrmException(e.getMessage(), e);
} catch (OrmException e) { } catch (OrmException e) {
Throwables.propagateIfInstanceOf(e.getCause(), QueryParseException.class); if (e.getCause() != null) {
Throwables.throwIfInstanceOf(e.getCause(), QueryParseException.class);
}
throw e; throw e;
} }
} }

View File

@@ -130,7 +130,7 @@ public abstract class RequestScopePropagator {
try { try {
wrapped.call(); wrapped.call();
} catch (Exception e) { } catch (Exception e) {
Throwables.propagateIfPossible(e); Throwables.throwIfUnchecked(e);
throw new RuntimeException(e); // Not possible. throw new RuntimeException(e); // Not possible.
} }
} }

View File

@@ -97,7 +97,7 @@ public class AliasCommand extends BaseCommand {
try { try {
cmd.destroy(); cmd.destroy();
} catch (Exception e) { } catch (Exception e) {
Throwables.propagateIfPossible(e); Throwables.throwIfUnchecked(e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@@ -136,7 +136,7 @@ final class DispatchCommand extends BaseCommand {
try { try {
cmd.destroy(); cmd.destroy();
} catch (Exception e) { } catch (Exception e) {
Throwables.propagateIfPossible(e); Throwables.throwIfUnchecked(e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@@ -153,7 +153,7 @@ public final class SuExec extends BaseCommand {
try { try {
cmd.destroy(); cmd.destroy();
} catch (Exception e) { } catch (Exception e) {
Throwables.propagateIfPossible(e); Throwables.throwIfUnchecked(e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@@ -70,7 +70,7 @@ maven_jar(
maven_jar( maven_jar(
name = 'guava', name = 'guava',
id = 'com.google.guava:guava:' + GUAVA_VERSION, id = 'com.google.guava:guava:' + GUAVA_VERSION,
sha1 = '6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9', sha1 = '4c2a4581b69b16a57968da32fcadb8e362b639b2',
license = 'Apache2.0', license = 'Apache2.0',
) )

View File

@@ -1,2 +1,2 @@
GUAVA_VERSION = '19.0' GUAVA_VERSION = '20.0-rc1'
GUAVA_DOC_URL = 'https://google.github.io/guava/releases/' + GUAVA_VERSION + '/api/docs/' GUAVA_DOC_URL = 'https://google.github.io/guava/releases/' + GUAVA_VERSION + '/api/docs/'