Revert Guava 20 features until we get the build working properly

*** Original change description ***

Remove deprecated methods with Guava 20 release

***

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=137945126
This commit is contained in:
mcilwain 2016-11-02 07:56:02 -07:00 committed by Ben McIlwain
parent 7206f88c6c
commit 1627bd4975
14 changed files with 29 additions and 34 deletions

View file

@ -76,7 +76,7 @@ public class TlsCredentials implements TransportCredentials {
static InetAddress parseInetAddress(String asciiAddr) { static InetAddress parseInetAddress(String asciiAddr) {
try { try {
return InetAddresses.forString(HostAndPort.fromString(asciiAddr).getHost()); return InetAddresses.forString(HostAndPort.fromString(asciiAddr).getHostText());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return null; return null;
} }

View file

@ -14,8 +14,8 @@
package google.registry.model; package google.registry.model;
import static com.google.common.base.Predicates.assignableFrom;
import static com.google.common.base.Predicates.or; import static com.google.common.base.Predicates.or;
import static com.google.common.base.Predicates.subtypeOf;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
@ -61,7 +61,7 @@ public final class SchemaVersion {
*/ */
public static String getSchema() { public static String getSchema() {
return FluentIterable.from(getAllPersistedTypes()) return FluentIterable.from(getAllPersistedTypes())
.filter(or(subtypeOf(Enum.class), subtypeOf(ImmutableObject.class))) .filter(or(assignableFrom(Enum.class), assignableFrom(ImmutableObject.class)))
.transform(new Function<Class<?>, String>() { .transform(new Function<Class<?>, String>() {
@Override @Override
public String apply(Class<?> clazz) { public String apply(Class<?> clazz) {

View file

@ -193,8 +193,7 @@ public class Lock extends ImmutableObject {
TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS,
true); true);
} catch (Exception e) { } catch (Exception e) {
Throwables.throwIfUnchecked(e); throw Throwables.propagate(e);
throw new RuntimeException(e);
} }
} }

View file

@ -97,7 +97,7 @@ final class Router {
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
// This means an exception was thrown during the injection process while instantiating // This means an exception was thrown during the injection process while instantiating
// the @Action class; we should propagate that underlying exception. // the @Action class; we should propagate that underlying exception.
Throwables.throwIfUnchecked(e.getCause()); Throwables.propagateIfPossible(e.getCause());
throw new AssertionError( throw new AssertionError(
"Component's @Action factory method somehow threw checked exception", e); "Component's @Action factory method somehow threw checked exception", e);
} }

View file

@ -14,7 +14,7 @@
package google.registry.tmch; package google.registry.tmch;
import static com.google.common.base.Throwables.throwIfInstanceOf; import static com.google.common.base.Throwables.propagateIfInstanceOf;
import static google.registry.util.CacheUtils.memoizeWithLongExpiration; import static google.registry.util.CacheUtils.memoizeWithLongExpiration;
import static google.registry.util.CacheUtils.memoizeWithShortExpiration; import static google.registry.util.CacheUtils.memoizeWithShortExpiration;
import static google.registry.util.ResourceUtils.readResourceUtf8; import static google.registry.util.ResourceUtils.readResourceUtf8;
@ -125,7 +125,7 @@ public final class TmchCertificateAuthority {
try { try {
return ROOT_CACHE.get(); return ROOT_CACHE.get();
} catch (RuntimeException e) { } catch (RuntimeException e) {
throwIfInstanceOf(e.getCause(), GeneralSecurityException.class); propagateIfInstanceOf(e.getCause(), GeneralSecurityException.class);
throw e; throw e;
} }
} }
@ -134,7 +134,7 @@ public final class TmchCertificateAuthority {
try { try {
return CRL_CACHE.get(); return CRL_CACHE.get();
} catch (RuntimeException e) { } catch (RuntimeException e) {
throwIfInstanceOf(e.getCause(), GeneralSecurityException.class); propagateIfInstanceOf(e.getCause(), GeneralSecurityException.class);
throw e; throw e;
} }
} }

View file

@ -17,7 +17,7 @@ package google.registry.tmch;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.getRootCause; import static com.google.common.base.Throwables.getRootCause;
import static com.google.common.base.Throwables.throwIfInstanceOf; import static com.google.common.base.Throwables.propagateIfInstanceOf;
import static google.registry.xml.XmlTransformer.loadXmlSchemas; import static google.registry.xml.XmlTransformer.loadXmlSchemas;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -96,7 +96,7 @@ public final class TmchXmlSignature {
isValid = signature.validate(context); isValid = signature.validate(context);
} catch (XMLSignatureException e) { } catch (XMLSignatureException e) {
Throwable cause = getRootCause(e); Throwable cause = getRootCause(e);
throwIfInstanceOf(cause, GeneralSecurityException.class); propagateIfInstanceOf(cause, GeneralSecurityException.class);
throw e; throw e;
} }
if (!isValid) { if (!isValid) {

View file

@ -163,7 +163,7 @@ class AppEngineConnection implements Connection {
} }
boolean isLocalhost() { boolean isLocalhost() {
return server.getHost().equals("localhost"); return server.getHostText().equals("localhost");
} }
private String getUserId() { private String getUserId() {

View file

@ -129,7 +129,7 @@ final class RegistryCli {
// RemoteApiCommands need to have the remote api installed to work. // RemoteApiCommands need to have the remote api installed to work.
RemoteApiInstaller installer = new RemoteApiInstaller(); RemoteApiInstaller installer = new RemoteApiInstaller();
RemoteApiOptions options = new RemoteApiOptions(); RemoteApiOptions options = new RemoteApiOptions();
options.server(connection.getServer().getHost(), connection.getServer().getPort()); options.server(connection.getServer().getHostText(), connection.getServer().getPort());
if (connection.isLocalhost()) { if (connection.isLocalhost()) {
// Use dev credentials for localhost. // Use dev credentials for localhost.
options.useDevelopmentServerCredential(); options.useDevelopmentServerCredential();

View file

@ -16,7 +16,7 @@ package google.registry.util;
import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfInstanceOf; import static com.google.common.base.Throwables.propagateIfInstanceOf;
import static com.google.common.io.BaseEncoding.base64; import static com.google.common.io.BaseEncoding.base64;
import static java.nio.charset.StandardCharsets.US_ASCII; import static java.nio.charset.StandardCharsets.US_ASCII;
@ -76,7 +76,7 @@ public final class X509Utils {
.from(CertificateFactory.getInstance("X.509").generateCertificates(input)) .from(CertificateFactory.getInstance("X.509").generateCertificates(input))
.filter(X509Certificate.class)); .filter(X509Certificate.class));
} catch (CertificateException e) { // CertificateParsingException by specification. } catch (CertificateException e) { // CertificateParsingException by specification.
throwIfInstanceOf(e, CertificateParsingException.class); propagateIfInstanceOf(e, CertificateParsingException.class);
throw new CertificateParsingException(e); throw new CertificateParsingException(e);
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
throw new CertificateParsingException("No X509Certificate found."); throw new CertificateParsingException("No X509Certificate found.");

View file

@ -14,7 +14,7 @@
package google.registry.xml; package google.registry.xml;
import static com.google.common.base.Throwables.throwIfInstanceOf; import static com.google.common.base.Throwables.propagateIfInstanceOf;
import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verify;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
@ -74,7 +74,7 @@ public final class XmlFragmentMarshaller {
try { try {
marshaller.marshal(element, os); marshaller.marshal(element, os);
} catch (JAXBException e) { } catch (JAXBException e) {
throwIfInstanceOf(e, MarshalException.class); propagateIfInstanceOf(e, MarshalException.class);
throw new RuntimeException("Mysterious XML exception", e); throw new RuntimeException("Mysterious XML exception", e);
} }
String fragment = new String(os.toByteArray(), UTF_8); String fragment = new String(os.toByteArray(), UTF_8);

View file

@ -62,10 +62,9 @@ public final class ServletWrapperDelegatorServlet extends HttpServlet {
try { try {
Uninterruptibles.getUninterruptibly(task); Uninterruptibles.getUninterruptibly(task);
} catch (ExecutionException e) { } catch (ExecutionException e) {
Throwables.throwIfInstanceOf(e.getCause(), ServletException.class); Throwables.propagateIfInstanceOf(e.getCause(), ServletException.class);
Throwables.throwIfInstanceOf(e.getCause(), IOException.class); Throwables.propagateIfInstanceOf(e.getCause(), IOException.class);
Throwables.throwIfUnchecked(e.getCause()); throw Throwables.propagate(e.getCause());
throw new RuntimeException(e.getCause());
} }
} }

View file

@ -91,8 +91,7 @@ public final class TestServer {
try { try {
server.start(); server.start();
} catch (Exception e) { } catch (Exception e) {
Throwables.throwIfUnchecked(e); throw Throwables.propagate(e);
throw new RuntimeException(e);
} }
UrlChecker.waitUntilAvailable(getUrl("/healthz"), STARTUP_TIMEOUT_MS); UrlChecker.waitUntilAvailable(getUrl("/healthz"), STARTUP_TIMEOUT_MS);
} }
@ -130,8 +129,7 @@ public final class TestServer {
} }
}, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS, true); }, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS, true);
} catch (Exception e) { } catch (Exception e) {
Throwables.throwIfUnchecked(e); throw Throwables.propagate(e);
throw new RuntimeException(e);
} }
} }
@ -168,20 +166,20 @@ public final class TestServer {
private static Connector createConnector(HostAndPort address) { private static Connector createConnector(HostAndPort address) {
SocketConnector connector = new SocketConnector(); SocketConnector connector = new SocketConnector();
connector.setHost(address.getHost()); connector.setHost(address.getHostText());
connector.setPort(address.getPortOrDefault(DEFAULT_PORT)); connector.setPort(address.getPortOrDefault(DEFAULT_PORT));
return connector; return connector;
} }
/** Converts a bind address into an address that other machines can use to connect here. */ /** Converts a bind address into an address that other machines can use to connect here. */
private static HostAndPort createUrlAddress(HostAndPort address) { private static HostAndPort createUrlAddress(HostAndPort address) {
if (address.getHost().equals("::") || address.getHost().equals("0.0.0.0")) { if (address.getHostText().equals("::") || address.getHostText().equals("0.0.0.0")) {
return address.getPortOrDefault(DEFAULT_PORT) == DEFAULT_PORT return address.getPortOrDefault(DEFAULT_PORT) == DEFAULT_PORT
? HostAndPort.fromHost(getCanonicalHostName()) ? HostAndPort.fromHost(getCanonicalHostName())
: HostAndPort.fromParts(getCanonicalHostName(), address.getPort()); : HostAndPort.fromParts(getCanonicalHostName(), address.getPort());
} else { } else {
return address.getPortOrDefault(DEFAULT_PORT) == DEFAULT_PORT return address.getPortOrDefault(DEFAULT_PORT) == DEFAULT_PORT
? HostAndPort.fromHost(address.getHost()) ? HostAndPort.fromHost(address.getHostText())
: address; : address;
} }
} }

View file

@ -45,8 +45,7 @@ final class UrlChecker {
} }
}, timeoutMs, TimeUnit.MILLISECONDS, true); }, timeoutMs, TimeUnit.MILLISECONDS, true);
} catch (Exception e) { } catch (Exception e) {
Throwables.throwIfUnchecked(e); throw Throwables.propagate(e);
throw new RuntimeException(e);
} }
} }

View file

@ -28,25 +28,25 @@ public class HostAndPortParameterTest {
@Test @Test
public void testConvert_hostOnly() throws Exception { public void testConvert_hostOnly() throws Exception {
assertThat(instance.convert("foo.bar").getHost()).isEqualTo("foo.bar"); assertThat(instance.convert("foo.bar").getHostText()).isEqualTo("foo.bar");
assertThat(instance.convert("foo.bar").getPortOrDefault(31337)).isEqualTo(31337); assertThat(instance.convert("foo.bar").getPortOrDefault(31337)).isEqualTo(31337);
} }
@Test @Test
public void testConvert_hostAndPort() throws Exception { public void testConvert_hostAndPort() throws Exception {
assertThat(instance.convert("foo.bar:1234").getHost()).isEqualTo("foo.bar"); assertThat(instance.convert("foo.bar:1234").getHostText()).isEqualTo("foo.bar");
assertThat(instance.convert("foo.bar:1234").getPortOrDefault(31337)).isEqualTo(1234); assertThat(instance.convert("foo.bar:1234").getPortOrDefault(31337)).isEqualTo(1234);
} }
@Test @Test
public void testConvert_ipv6_hostOnly() throws Exception { public void testConvert_ipv6_hostOnly() throws Exception {
assertThat(instance.convert("[feed:a:bee]").getHost()).isEqualTo("feed:a:bee"); assertThat(instance.convert("[feed:a:bee]").getHostText()).isEqualTo("feed:a:bee");
assertThat(instance.convert("[feed:a:bee]").getPortOrDefault(31337)).isEqualTo(31337); assertThat(instance.convert("[feed:a:bee]").getPortOrDefault(31337)).isEqualTo(31337);
} }
@Test @Test
public void testConvert_ipv6_hostAndPort() throws Exception { public void testConvert_ipv6_hostAndPort() throws Exception {
assertThat(instance.convert("[feed:a:bee]:1234").getHost()).isEqualTo("feed:a:bee"); assertThat(instance.convert("[feed:a:bee]:1234").getHostText()).isEqualTo("feed:a:bee");
assertThat(instance.convert("[feed:a:bee]:1234").getPortOrDefault(31337)).isEqualTo(1234); assertThat(instance.convert("[feed:a:bee]:1234").getPortOrDefault(31337)).isEqualTo(1234);
} }
} }