mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
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:
parent
7206f88c6c
commit
1627bd4975
14 changed files with 29 additions and 34 deletions
|
@ -76,7 +76,7 @@ public class TlsCredentials implements TransportCredentials {
|
|||
|
||||
static InetAddress parseInetAddress(String asciiAddr) {
|
||||
try {
|
||||
return InetAddresses.forString(HostAndPort.fromString(asciiAddr).getHost());
|
||||
return InetAddresses.forString(HostAndPort.fromString(asciiAddr).getHostText());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
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.subtypeOf;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -61,7 +61,7 @@ public final class SchemaVersion {
|
|||
*/
|
||||
public static String getSchema() {
|
||||
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>() {
|
||||
@Override
|
||||
public String apply(Class<?> clazz) {
|
||||
|
|
|
@ -193,8 +193,7 @@ public class Lock extends ImmutableObject {
|
|||
TimeUnit.MILLISECONDS,
|
||||
true);
|
||||
} catch (Exception e) {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ final class Router {
|
|||
} catch (InvocationTargetException e) {
|
||||
// This means an exception was thrown during the injection process while instantiating
|
||||
// the @Action class; we should propagate that underlying exception.
|
||||
Throwables.throwIfUnchecked(e.getCause());
|
||||
Throwables.propagateIfPossible(e.getCause());
|
||||
throw new AssertionError(
|
||||
"Component's @Action factory method somehow threw checked exception", e);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
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.memoizeWithShortExpiration;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
|
@ -125,7 +125,7 @@ public final class TmchCertificateAuthority {
|
|||
try {
|
||||
return ROOT_CACHE.get();
|
||||
} catch (RuntimeException e) {
|
||||
throwIfInstanceOf(e.getCause(), GeneralSecurityException.class);
|
||||
propagateIfInstanceOf(e.getCause(), GeneralSecurityException.class);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public final class TmchCertificateAuthority {
|
|||
try {
|
||||
return CRL_CACHE.get();
|
||||
} catch (RuntimeException e) {
|
||||
throwIfInstanceOf(e.getCause(), GeneralSecurityException.class);
|
||||
propagateIfInstanceOf(e.getCause(), GeneralSecurityException.class);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package google.registry.tmch;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
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 com.google.common.collect.ImmutableList;
|
||||
|
@ -96,7 +96,7 @@ public final class TmchXmlSignature {
|
|||
isValid = signature.validate(context);
|
||||
} catch (XMLSignatureException e) {
|
||||
Throwable cause = getRootCause(e);
|
||||
throwIfInstanceOf(cause, GeneralSecurityException.class);
|
||||
propagateIfInstanceOf(cause, GeneralSecurityException.class);
|
||||
throw e;
|
||||
}
|
||||
if (!isValid) {
|
||||
|
|
|
@ -163,7 +163,7 @@ class AppEngineConnection implements Connection {
|
|||
}
|
||||
|
||||
boolean isLocalhost() {
|
||||
return server.getHost().equals("localhost");
|
||||
return server.getHostText().equals("localhost");
|
||||
}
|
||||
|
||||
private String getUserId() {
|
||||
|
|
|
@ -129,7 +129,7 @@ final class RegistryCli {
|
|||
// RemoteApiCommands need to have the remote api installed to work.
|
||||
RemoteApiInstaller installer = new RemoteApiInstaller();
|
||||
RemoteApiOptions options = new RemoteApiOptions();
|
||||
options.server(connection.getServer().getHost(), connection.getServer().getPort());
|
||||
options.server(connection.getServer().getHostText(), connection.getServer().getPort());
|
||||
if (connection.isLocalhost()) {
|
||||
// Use dev credentials for localhost.
|
||||
options.useDevelopmentServerCredential();
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.util;
|
|||
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
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 java.nio.charset.StandardCharsets.US_ASCII;
|
||||
|
||||
|
@ -76,7 +76,7 @@ public final class X509Utils {
|
|||
.from(CertificateFactory.getInstance("X.509").generateCertificates(input))
|
||||
.filter(X509Certificate.class));
|
||||
} catch (CertificateException e) { // CertificateParsingException by specification.
|
||||
throwIfInstanceOf(e, CertificateParsingException.class);
|
||||
propagateIfInstanceOf(e, CertificateParsingException.class);
|
||||
throw new CertificateParsingException(e);
|
||||
} catch (NoSuchElementException e) {
|
||||
throw new CertificateParsingException("No X509Certificate found.");
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
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 java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public final class XmlFragmentMarshaller {
|
|||
try {
|
||||
marshaller.marshal(element, os);
|
||||
} catch (JAXBException e) {
|
||||
throwIfInstanceOf(e, MarshalException.class);
|
||||
propagateIfInstanceOf(e, MarshalException.class);
|
||||
throw new RuntimeException("Mysterious XML exception", e);
|
||||
}
|
||||
String fragment = new String(os.toByteArray(), UTF_8);
|
||||
|
|
|
@ -62,10 +62,9 @@ public final class ServletWrapperDelegatorServlet extends HttpServlet {
|
|||
try {
|
||||
Uninterruptibles.getUninterruptibly(task);
|
||||
} catch (ExecutionException e) {
|
||||
Throwables.throwIfInstanceOf(e.getCause(), ServletException.class);
|
||||
Throwables.throwIfInstanceOf(e.getCause(), IOException.class);
|
||||
Throwables.throwIfUnchecked(e.getCause());
|
||||
throw new RuntimeException(e.getCause());
|
||||
Throwables.propagateIfInstanceOf(e.getCause(), ServletException.class);
|
||||
Throwables.propagateIfInstanceOf(e.getCause(), IOException.class);
|
||||
throw Throwables.propagate(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,7 @@ public final class TestServer {
|
|||
try {
|
||||
server.start();
|
||||
} catch (Exception e) {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
UrlChecker.waitUntilAvailable(getUrl("/healthz"), STARTUP_TIMEOUT_MS);
|
||||
}
|
||||
|
@ -130,8 +129,7 @@ public final class TestServer {
|
|||
}
|
||||
}, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS, true);
|
||||
} catch (Exception e) {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,20 +166,20 @@ public final class TestServer {
|
|||
|
||||
private static Connector createConnector(HostAndPort address) {
|
||||
SocketConnector connector = new SocketConnector();
|
||||
connector.setHost(address.getHost());
|
||||
connector.setHost(address.getHostText());
|
||||
connector.setPort(address.getPortOrDefault(DEFAULT_PORT));
|
||||
return connector;
|
||||
}
|
||||
|
||||
/** Converts a bind address into an address that other machines can use to connect here. */
|
||||
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
|
||||
? HostAndPort.fromHost(getCanonicalHostName())
|
||||
: HostAndPort.fromParts(getCanonicalHostName(), address.getPort());
|
||||
} else {
|
||||
return address.getPortOrDefault(DEFAULT_PORT) == DEFAULT_PORT
|
||||
? HostAndPort.fromHost(address.getHost())
|
||||
? HostAndPort.fromHost(address.getHostText())
|
||||
: address;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,7 @@ final class UrlChecker {
|
|||
}
|
||||
}, timeoutMs, TimeUnit.MILLISECONDS, true);
|
||||
} catch (Exception e) {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,25 +28,25 @@ public class HostAndPortParameterTest {
|
|||
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue