mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 20:17:51 +02:00
Replace Throwables.propagate and variants with Guava 20 versions
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146250470
This commit is contained in:
parent
a061f74ee7
commit
e2e37dc9f3
8 changed files with 25 additions and 20 deletions
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.server;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Throwables.throwIfUnchecked;
|
||||
import static com.google.common.collect.Iterables.getFirst;
|
||||
import static com.google.common.collect.Iterables.skip;
|
||||
import static com.google.common.collect.Sets.newLinkedHashSet;
|
||||
|
@ -24,7 +25,6 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|||
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.googlecode.objectify.VoidWork;
|
||||
|
@ -193,7 +193,8 @@ public class Lock extends ImmutableObject {
|
|||
TimeUnit.MILLISECONDS,
|
||||
true);
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
|
||||
package google.registry.request;
|
||||
|
||||
import static com.google.common.base.Throwables.throwIfUnchecked;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Ordering;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -100,7 +101,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.propagateIfPossible(e.getCause());
|
||||
throwIfUnchecked(e.getCause());
|
||||
throw new AssertionError(
|
||||
"Component's @Action factory method somehow threw checked exception", 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.propagateIfInstanceOf;
|
||||
import static com.google.common.base.Throwables.throwIfInstanceOf;
|
||||
import static google.registry.xml.XmlTransformer.loadXmlSchemas;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
@ -101,8 +101,7 @@ public final class TmchXmlSignature {
|
|||
try {
|
||||
isValid = signature.validate(context);
|
||||
} catch (XMLSignatureException e) {
|
||||
Throwable cause = getRootCause(e);
|
||||
propagateIfInstanceOf(cause, GeneralSecurityException.class);
|
||||
throwIfInstanceOf(getRootCause(e), GeneralSecurityException.class);
|
||||
throw e;
|
||||
}
|
||||
if (!isValid) {
|
||||
|
|
|
@ -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.propagateIfInstanceOf;
|
||||
import static com.google.common.base.Throwables.throwIfInstanceOf;
|
||||
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.
|
||||
propagateIfInstanceOf(e, CertificateParsingException.class);
|
||||
throwIfInstanceOf(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.propagateIfInstanceOf;
|
||||
import static com.google.common.base.Throwables.throwIfInstanceOf;
|
||||
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) {
|
||||
propagateIfInstanceOf(e, MarshalException.class);
|
||||
throwIfInstanceOf(e, MarshalException.class);
|
||||
throw new RuntimeException("Mysterious XML exception", e);
|
||||
}
|
||||
String fragment = new String(os.toByteArray(), UTF_8);
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
package google.registry.server;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Throwables.throwIfInstanceOf;
|
||||
import static google.registry.util.TypeUtils.instantiate;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.Uninterruptibles;
|
||||
import java.io.IOException;
|
||||
|
@ -86,9 +86,9 @@ public final class ServletWrapperDelegatorServlet extends HttpServlet {
|
|||
try {
|
||||
Uninterruptibles.getUninterruptibly(task);
|
||||
} catch (ExecutionException e) {
|
||||
Throwables.propagateIfInstanceOf(e.getCause(), ServletException.class);
|
||||
Throwables.propagateIfInstanceOf(e.getCause(), IOException.class);
|
||||
throw Throwables.propagate(e.getCause());
|
||||
throwIfInstanceOf(e.getCause(), ServletException.class);
|
||||
throwIfInstanceOf(e.getCause(), IOException.class);
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
package google.registry.server;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Throwables.throwIfUnchecked;
|
||||
import static com.google.common.util.concurrent.Runnables.doNothing;
|
||||
import static google.registry.util.NetworkUtils.getCanonicalHostName;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import com.google.common.util.concurrent.SimpleTimeLimiter;
|
||||
|
@ -97,7 +97,8 @@ public final class TestServer {
|
|||
try {
|
||||
server.start();
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UrlChecker.waitUntilAvailable(getUrl("/healthz"), STARTUP_TIMEOUT_MS);
|
||||
}
|
||||
|
@ -135,7 +136,8 @@ public final class TestServer {
|
|||
}
|
||||
}, SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS, true);
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
package google.registry.server;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import static com.google.common.base.Throwables.throwIfUnchecked;
|
||||
|
||||
import com.google.common.util.concurrent.SimpleTimeLimiter;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
|
@ -45,7 +46,8 @@ final class UrlChecker {
|
|||
}
|
||||
}, timeoutMs, TimeUnit.MILLISECONDS, true);
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue