diff --git a/buildSrc/src/main/java/google/registry/gradle/plugin/ProjectData.java b/buildSrc/src/main/java/google/registry/gradle/plugin/ProjectData.java index 68eaa8bdb..1eef69a93 100644 --- a/buildSrc/src/main/java/google/registry/gradle/plugin/ProjectData.java +++ b/buildSrc/src/main/java/google/registry/gradle/plugin/ProjectData.java @@ -91,7 +91,7 @@ abstract class ProjectData { /** The task was actually run and has finished successfully. */ SUCCESS, /** The task was up-to-date and successful, and hence didn't need to run again. */ - UP_TO_DATE; + UP_TO_DATE } abstract String uniqueName(); diff --git a/core/src/main/java/google/registry/beam/datastore/DatastoreV1.java b/core/src/main/java/google/registry/beam/datastore/DatastoreV1.java index 2a09ebf66..d6fdb640f 100644 --- a/core/src/main/java/google/registry/beam/datastore/DatastoreV1.java +++ b/core/src/main/java/google/registry/beam/datastore/DatastoreV1.java @@ -505,7 +505,7 @@ public class DatastoreV1 { } @StartBundle - public void startBundle(StartBundleContext c) throws Exception { + public void startBundle(StartBundleContext c) { datastore = datastoreFactory.getDatastore( c.getPipelineOptions(), v1Options.getProjectId(), v1Options.getLocalhost()); @@ -548,7 +548,7 @@ public class DatastoreV1 { } @StartBundle - public void startBundle(StartBundleContext c) throws Exception { + public void startBundle(StartBundleContext c) { datastore = datastoreFactory.getDatastore( c.getPipelineOptions(), options.getProjectId(), options.getLocalhost()); @@ -556,7 +556,7 @@ public class DatastoreV1 { } @ProcessElement - public void processElement(ProcessContext c) throws Exception { + public void processElement(ProcessContext c) { Query query = c.element(); // If query has a user set limit, then do not split. @@ -626,7 +626,7 @@ public class DatastoreV1 { } @StartBundle - public void startBundle(StartBundleContext c) throws Exception { + public void startBundle(StartBundleContext c) { datastore = datastoreFactory.getDatastore( c.getPipelineOptions(), options.getProjectId(), options.getLocalhost()); diff --git a/core/src/main/java/google/registry/beam/initsql/BackupPaths.java b/core/src/main/java/google/registry/beam/initsql/BackupPaths.java index c5be89061..8b42c450e 100644 --- a/core/src/main/java/google/registry/beam/initsql/BackupPaths.java +++ b/core/src/main/java/google/registry/beam/initsql/BackupPaths.java @@ -93,7 +93,7 @@ public final class BackupPaths { checkArgument(!isNullOrEmpty(exportDir), "Null or empty exportDir."); checkArgument(!isNullOrEmpty(kind), "Null or empty kind."); checkArgument(shard >= 0, "Negative shard %s not allowed.", shard); - return String.format(EXPORT_PATTERN_TEMPLATE, exportDir, kind, Integer.toString(shard)); + return String.format(EXPORT_PATTERN_TEMPLATE, exportDir, kind, shard); } /** Returns an {@link ImmutableList} of regex patterns that match all CommitLog files. */ diff --git a/core/src/main/java/google/registry/model/domain/DomainContent.java b/core/src/main/java/google/registry/model/domain/DomainContent.java index 5a2236aff..189fd8646 100644 --- a/core/src/main/java/google/registry/model/domain/DomainContent.java +++ b/core/src/main/java/google/registry/model/domain/DomainContent.java @@ -337,7 +337,7 @@ public class DomainContent extends EppResource @PostLoad @SuppressWarnings("UnusedMethod") - private final void postLoad() { + private void postLoad() { // Reconstitute the contact list. ImmutableSet.Builder contactsBuilder = new ImmutableSet.Builder<>(); diff --git a/core/src/main/java/google/registry/persistence/HibernateSchemaExporter.java b/core/src/main/java/google/registry/persistence/HibernateSchemaExporter.java index 09815a738..4ef3b1fa5 100644 --- a/core/src/main/java/google/registry/persistence/HibernateSchemaExporter.java +++ b/core/src/main/java/google/registry/persistence/HibernateSchemaExporter.java @@ -51,7 +51,7 @@ public class HibernateSchemaExporter { } /** Exports DDL script to the {@code outputFile} for the given {@code entityClasses}. */ - public void export(ImmutableList entityClasses, File outputFile) { + public void export(ImmutableList> entityClasses, File outputFile) { // Configure Hibernate settings. Map settings = Maps.newHashMap(); settings.put(Environment.DIALECT, NomulusPostgreSQLDialect.class.getName()); @@ -85,7 +85,7 @@ public class HibernateSchemaExporter { } } - private ImmutableList findAllConverters() { + private ImmutableList> findAllConverters() { return PersistenceXmlUtility.getManagedClasses().stream() .filter(AttributeConverter.class::isAssignableFrom) .collect(toImmutableList()); diff --git a/core/src/main/java/google/registry/persistence/PersistenceXmlUtility.java b/core/src/main/java/google/registry/persistence/PersistenceXmlUtility.java index 8bd3f90d7..018e80555 100644 --- a/core/src/main/java/google/registry/persistence/PersistenceXmlUtility.java +++ b/core/src/main/java/google/registry/persistence/PersistenceXmlUtility.java @@ -41,7 +41,7 @@ public class PersistenceXmlUtility { } /** Returns all managed classes defined in persistence.xml. */ - public static ImmutableList getManagedClasses() { + public static ImmutableList> getManagedClasses() { return getParsedPersistenceXmlDescriptor().getManagedClassNames().stream() .map( className -> { diff --git a/core/src/main/java/google/registry/persistence/converter/DateTimeConverter.java b/core/src/main/java/google/registry/persistence/converter/DateTimeConverter.java index 41020fc54..a8095f20f 100644 --- a/core/src/main/java/google/registry/persistence/converter/DateTimeConverter.java +++ b/core/src/main/java/google/registry/persistence/converter/DateTimeConverter.java @@ -35,7 +35,6 @@ public class DateTimeConverter implements AttributeConverter void assertDelete(VKey key); + void assertDelete(VKey key); /** * Releases all resources and shuts down. diff --git a/core/src/main/java/google/registry/persistence/transaction/Transaction.java b/core/src/main/java/google/registry/persistence/transaction/Transaction.java index 7bc223464..65ba63479 100644 --- a/core/src/main/java/google/registry/persistence/transaction/Transaction.java +++ b/core/src/main/java/google/registry/persistence/transaction/Transaction.java @@ -165,7 +165,7 @@ public class Transaction extends ImmutableObject implements Buildable { enum Type { UPDATE, DELETE - }; + } /** Write the changes in the mutation to the datastore. */ public abstract void writeToDatastore(); diff --git a/core/src/main/java/google/registry/privileges/secretmanager/SqlUser.java b/core/src/main/java/google/registry/privileges/secretmanager/SqlUser.java index a9e2d5213..956a27b5d 100644 --- a/core/src/main/java/google/registry/privileges/secretmanager/SqlUser.java +++ b/core/src/main/java/google/registry/privileges/secretmanager/SqlUser.java @@ -54,7 +54,7 @@ public abstract class SqlUser { * Credential for RegistryTool. This is temporary, and will be removed when tool users are * assigned their personal credentials. */ - TOOL; + TOOL } /** Information of a RobotUser for privilege management purposes. */ diff --git a/core/src/main/java/google/registry/rde/BrdaCopyAction.java b/core/src/main/java/google/registry/rde/BrdaCopyAction.java index 8e935c1f6..75a57cd15 100644 --- a/core/src/main/java/google/registry/rde/BrdaCopyAction.java +++ b/core/src/main/java/google/registry/rde/BrdaCopyAction.java @@ -32,7 +32,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.inject.Inject; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPublicKey; @@ -79,12 +78,12 @@ public final class BrdaCopyAction implements Runnable { public void run() { try { copyAsRyde(); - } catch (IOException | PGPException e) { + } catch (IOException e) { throw new RuntimeException(e); } } - private void copyAsRyde() throws IOException, PGPException { + private void copyAsRyde() throws IOException { String prefix = RdeNamingUtils.makeRydeFilename(tld, watermark, THIN, 1, 0); GcsFilename xmlFilename = new GcsFilename(stagingBucket, prefix + ".xml.ghostryde"); GcsFilename xmlLengthFilename = new GcsFilename(stagingBucket, prefix + ".xml.length"); diff --git a/core/src/main/java/google/registry/rde/Ghostryde.java b/core/src/main/java/google/registry/rde/Ghostryde.java index 9787bba9d..51393c6ac 100644 --- a/core/src/main/java/google/registry/rde/Ghostryde.java +++ b/core/src/main/java/google/registry/rde/Ghostryde.java @@ -37,7 +37,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.annotation.Nullable; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPublicKey; import org.joda.time.DateTime; @@ -118,11 +117,8 @@ public final class Ghostryde { static final String INNER_FILENAME = "file.xml"; static final DateTime INNER_MODIFICATION_TIME = DateTime.parse("2000-01-01TZ"); - /** - * Creates a ghostryde file from an in-memory byte array. - */ - public static byte[] encode(byte[] data, PGPPublicKey key) - throws IOException, PGPException { + /** Creates a ghostryde file from an in-memory byte array. */ + public static byte[] encode(byte[] data, PGPPublicKey key) throws IOException { checkNotNull(data, "data"); checkArgument(key.isEncryptionKey(), "not an encryption key"); ByteArrayOutputStream output = new ByteArrayOutputStream(); @@ -132,11 +128,8 @@ public final class Ghostryde { return output.toByteArray(); } - /** - * Deciphers a ghostryde file from an in-memory byte array. - */ - public static byte[] decode(byte[] data, PGPPrivateKey key) - throws IOException, PGPException { + /** Deciphers a ghostryde file from an in-memory byte array. */ + public static byte[] decode(byte[] data, PGPPrivateKey key) throws IOException { checkNotNull(data, "data"); ByteArrayInputStream dataStream = new ByteArrayInputStream(data); ByteArrayOutputStream output = new ByteArrayOutputStream(); diff --git a/core/src/main/java/google/registry/rde/RdeReportAction.java b/core/src/main/java/google/registry/rde/RdeReportAction.java index eca188709..0f017bd26 100644 --- a/core/src/main/java/google/registry/rde/RdeReportAction.java +++ b/core/src/main/java/google/registry/rde/RdeReportAction.java @@ -42,7 +42,6 @@ import google.registry.request.auth.Auth; import java.io.IOException; import java.io.InputStream; import javax.inject.Inject; -import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPrivateKey; import org.joda.time.DateTime; import org.joda.time.Duration; @@ -96,7 +95,7 @@ public final class RdeReportAction implements Runnable, EscrowTask { } /** Reads and decrypts the XML file from cloud storage. */ - private byte[] readReportFromGcs(GcsFilename reportFilename) throws IOException, PGPException { + private byte[] readReportFromGcs(GcsFilename reportFilename) throws IOException { try (InputStream gcsInput = gcsUtils.openInputStream(reportFilename); InputStream ghostrydeDecoder = Ghostryde.decoder(gcsInput, stagingDecryptionKey)) { return ByteStreams.toByteArray(ghostrydeDecoder); diff --git a/core/src/main/java/google/registry/rde/RydeEncoder.java b/core/src/main/java/google/registry/rde/RydeEncoder.java index fe3b49df4..da3dfd1c5 100644 --- a/core/src/main/java/google/registry/rde/RydeEncoder.java +++ b/core/src/main/java/google/registry/rde/RydeEncoder.java @@ -74,9 +74,8 @@ public final class RydeEncoder extends FilterOutputStream { OutputStream kompressor = closer.register(openCompressor(encryptLayer)); OutputStream fileLayer = closer.register(openPgpFileWriter(kompressor, filenamePrefix + ".tar", modified)); - OutputStream tarLayer = + this.out = closer.register(openTarWriter(fileLayer, dataLength, filenamePrefix + ".xml", modified)); - this.out = tarLayer; } /** diff --git a/core/src/main/java/google/registry/reporting/icann/ActivityReportingQueryBuilder.java b/core/src/main/java/google/registry/reporting/icann/ActivityReportingQueryBuilder.java index aec5b1f05..cc6552c94 100644 --- a/core/src/main/java/google/registry/reporting/icann/ActivityReportingQueryBuilder.java +++ b/core/src/main/java/google/registry/reporting/icann/ActivityReportingQueryBuilder.java @@ -128,7 +128,7 @@ public final class ActivityReportingQueryBuilder implements QueryBuilder { return queriesBuilder.build(); } - public void prepareForQuery(YearMonth yearMonth) throws Exception { + public void prepareForQuery(YearMonth yearMonth) throws InterruptedException { dnsCountQueryCoordinator.prepareForQuery(yearMonth); } } diff --git a/core/src/main/java/google/registry/reporting/icann/BasicDnsCountQueryCoordinator.java b/core/src/main/java/google/registry/reporting/icann/BasicDnsCountQueryCoordinator.java index 2b640b7dc..f5c4ceab3 100644 --- a/core/src/main/java/google/registry/reporting/icann/BasicDnsCountQueryCoordinator.java +++ b/core/src/main/java/google/registry/reporting/icann/BasicDnsCountQueryCoordinator.java @@ -35,5 +35,5 @@ public class BasicDnsCountQueryCoordinator implements DnsCountQueryCoordinator { } @Override - public void prepareForQuery(YearMonth yearMonth) throws Exception {} + public void prepareForQuery(YearMonth yearMonth) {} } diff --git a/core/src/main/java/google/registry/reporting/icann/DnsCountQueryCoordinator.java b/core/src/main/java/google/registry/reporting/icann/DnsCountQueryCoordinator.java index be8d6f902..ebaf28f4f 100644 --- a/core/src/main/java/google/registry/reporting/icann/DnsCountQueryCoordinator.java +++ b/core/src/main/java/google/registry/reporting/icann/DnsCountQueryCoordinator.java @@ -32,7 +32,7 @@ public interface DnsCountQueryCoordinator { /** * Class to carry parameters for a new coordinator. * - * If your report query requires any additional parameters, add them here. + *

If your report query requires any additional parameters, add them here. */ class Params { public BigqueryConnection bigquery; @@ -49,6 +49,12 @@ public interface DnsCountQueryCoordinator { /** Creates the string used to query bigtable for DNS count information. */ String createQuery(YearMonth yearMonth); - /** Do any necessry preparation for the DNS query. */ - void prepareForQuery(YearMonth yearMonth) throws Exception; + /** + * Do any necessary preparation for the DNS query. + * + *

This potentially throws {@link InterruptedException} because some implementations use + * interruptible futures to prepare the query (and the correct thing to do with such exceptions is + * to handle them correctly or propagate them as-is, no {@link RuntimeException} wrapping). + */ + void prepareForQuery(YearMonth yearMonth) throws InterruptedException; } diff --git a/core/src/main/java/google/registry/tmch/ClaimsListParser.java b/core/src/main/java/google/registry/tmch/ClaimsListParser.java index b2b83dcc9..61aaeef50 100644 --- a/core/src/main/java/google/registry/tmch/ClaimsListParser.java +++ b/core/src/main/java/google/registry/tmch/ClaimsListParser.java @@ -46,7 +46,7 @@ public class ClaimsListParser { checkArgument(firstLine.size() == 2, String.format( "Line 1: Expected 2 elements, found %d", firstLine.size())); - Integer version = Integer.valueOf(firstLine.get(0)); + int version = Integer.parseInt(firstLine.get(0)); DateTime creationTime = DateTime.parse(firstLine.get(1)); checkArgument(version == 1, String.format( "Line 1: Expected version 1, found %d", version)); diff --git a/core/src/main/java/google/registry/tmch/Marksdb.java b/core/src/main/java/google/registry/tmch/Marksdb.java index 2d771e910..40109b091 100644 --- a/core/src/main/java/google/registry/tmch/Marksdb.java +++ b/core/src/main/java/google/registry/tmch/Marksdb.java @@ -151,7 +151,7 @@ public final class Marksdb { * *

Note that the DNL is long, hence truncating it instead of logging the whole thing. */ - private static void logFetchedBytes(String sourceUrl, byte[] bytes) throws IOException { + private static void logFetchedBytes(String sourceUrl, byte[] bytes) { logger.atInfo().log( "Fetched contents of %s -- Size: %d bytes; first %d chars:\n\n%s%s", sourceUrl, diff --git a/core/src/main/java/google/registry/tmch/SmdrlCsvParser.java b/core/src/main/java/google/registry/tmch/SmdrlCsvParser.java index 9b5178b98..2b76c8468 100644 --- a/core/src/main/java/google/registry/tmch/SmdrlCsvParser.java +++ b/core/src/main/java/google/registry/tmch/SmdrlCsvParser.java @@ -42,7 +42,7 @@ public final class SmdrlCsvParser { List firstLine = Splitter.on(',').splitToList(lines.get(0)); checkArgument(firstLine.size() == 2, String.format( "Line 1: Expected 2 elements, found %d", firstLine.size())); - Integer version = Integer.valueOf(firstLine.get(0)); + int version = Integer.parseInt(firstLine.get(0)); checkArgument(version == 1, String.format( "Line 1: Expected version 1, found %d", version)); DateTime creationTime = DateTime.parse(firstLine.get(1)).withZone(UTC); diff --git a/core/src/main/java/google/registry/tools/BigqueryParameters.java b/core/src/main/java/google/registry/tools/BigqueryParameters.java index 2a7d9c08e..d884108ab 100644 --- a/core/src/main/java/google/registry/tools/BigqueryParameters.java +++ b/core/src/main/java/google/registry/tools/BigqueryParameters.java @@ -52,7 +52,7 @@ final class BigqueryParameters { private int bigqueryNumThreads = DEFAULT_NUM_THREADS; /** Returns a new BigqueryConnection constructed according to the delegate's flag settings. */ - BigqueryConnection newConnection(BigqueryConnection.Builder connectionBuilder) throws Exception { + BigqueryConnection newConnection(BigqueryConnection.Builder connectionBuilder) { return connectionBuilder .setExecutorService(Executors.newFixedThreadPool(bigqueryNumThreads)) .setDatasetId(bigqueryDataset) diff --git a/core/src/main/java/google/registry/tools/ConfirmingCommand.java b/core/src/main/java/google/registry/tools/ConfirmingCommand.java index 496dff30a..1cb8fe37a 100644 --- a/core/src/main/java/google/registry/tools/ConfirmingCommand.java +++ b/core/src/main/java/google/registry/tools/ConfirmingCommand.java @@ -47,7 +47,7 @@ public abstract class ConfirmingCommand implements Command { } /** Run any pre-execute command checks and return true if they all pass. */ - protected boolean checkExecutionState() throws Exception { + protected boolean checkExecutionState() { return true; } diff --git a/core/src/main/java/google/registry/tools/GetPremiumListCommand.java b/core/src/main/java/google/registry/tools/GetPremiumListCommand.java index a49ee1be5..94b01aab6 100644 --- a/core/src/main/java/google/registry/tools/GetPremiumListCommand.java +++ b/core/src/main/java/google/registry/tools/GetPremiumListCommand.java @@ -31,7 +31,7 @@ public class GetPremiumListCommand implements CommandWithRemoteApi { private List mainParameters; @Override - public void run() throws Exception { + public void run() { for (String premiumListName : mainParameters) { if (PremiumListDualDao.exists(premiumListName)) { System.out.printf( @@ -42,7 +42,7 @@ public class GetPremiumListCommand implements CommandWithRemoteApi { .map(PremiumListEntry::toString) .collect(Collectors.joining("\n"))); } else { - System.out.println(String.format("No list found with name %s.", premiumListName)); + System.out.printf("No list found with name %s.%n", premiumListName); } } } diff --git a/core/src/main/java/google/registry/tools/ReadEntityFromKeyPathCommand.java b/core/src/main/java/google/registry/tools/ReadEntityFromKeyPathCommand.java index 2f83dafcf..6900b1630 100644 --- a/core/src/main/java/google/registry/tools/ReadEntityFromKeyPathCommand.java +++ b/core/src/main/java/google/registry/tools/ReadEntityFromKeyPathCommand.java @@ -66,11 +66,9 @@ abstract class ReadEntityFromKeyPathCommand extends MutatingCommand { Key untypedKey = parseKeyPath(keyPath); Object entity = ofy().load().key(untypedKey).now(); if (entity == null) { - System.err.println( - String.format( - "Entity %s read from %s doesn't exist in Datastore! Skipping.", - untypedKey, - keyPathsFile == null ? "STDIN" : "File " + keyPathsFile.getAbsolutePath())); + System.err.printf( + "Entity %s read from %s doesn't exist in Datastore! Skipping.%n", + untypedKey, keyPathsFile == null ? "STDIN" : "File " + keyPathsFile.getAbsolutePath()); continue; } Class clazz = new TypeInstantiator(getClass()) {}.getExactType(); diff --git a/core/src/main/java/google/registry/tools/SetupOteCommand.java b/core/src/main/java/google/registry/tools/SetupOteCommand.java index a564c1fdf..fcd9e5fd7 100644 --- a/core/src/main/java/google/registry/tools/SetupOteCommand.java +++ b/core/src/main/java/google/registry/tools/SetupOteCommand.java @@ -123,7 +123,7 @@ final class SetupOteCommand extends ConfirmingCommand implements CommandWithRemo } @Override - public String execute() throws Exception { + public String execute() { ImmutableMap clientIdToTld = oteAccountBuilder.buildAndPersist(); StringBuilder output = new StringBuilder(); diff --git a/core/src/main/java/google/registry/tools/params/ParameterConverterValidator.java b/core/src/main/java/google/registry/tools/params/ParameterConverterValidator.java index b296d82bc..6b59efcef 100644 --- a/core/src/main/java/google/registry/tools/params/ParameterConverterValidator.java +++ b/core/src/main/java/google/registry/tools/params/ParameterConverterValidator.java @@ -40,9 +40,7 @@ public abstract class ParameterConverterValidator try { convert(value); } catch (IllegalArgumentException e) { - ParameterException pe = - new ParameterException(String.format("%s=%s %s", name, value, messageForInvalid), e); - throw pe; + throw new ParameterException(String.format("%s=%s %s", name, value, messageForInvalid), e); } } } diff --git a/core/src/nonprod/java/google/registry/tools/GenerateSqlErDiagramCommand.java b/core/src/nonprod/java/google/registry/tools/GenerateSqlErDiagramCommand.java index df46f74de..d421b7904 100644 --- a/core/src/nonprod/java/google/registry/tools/GenerateSqlErDiagramCommand.java +++ b/core/src/nonprod/java/google/registry/tools/GenerateSqlErDiagramCommand.java @@ -130,15 +130,14 @@ public class GenerateSqlErDiagramCommand implements Command { doc.select("body > table > tbody") .first() .append( - String.format( - "" - + "last flyway file" - + "" - + getLastFlywayFileName() - + "" - + "")); + "" + + "last flyway file" + + "" + + getLastFlywayFileName() + + "" + + ""); // Add pan and zoom support for the embedded SVG in the HTML. StringBuilder svgPanZoomLib = diff --git a/core/src/test/java/google/registry/batch/AsyncTaskEnqueuerTest.java b/core/src/test/java/google/registry/batch/AsyncTaskEnqueuerTest.java index 7eef6bbd1..67e8a081c 100644 --- a/core/src/test/java/google/registry/batch/AsyncTaskEnqueuerTest.java +++ b/core/src/test/java/google/registry/batch/AsyncTaskEnqueuerTest.java @@ -135,7 +135,7 @@ public class AsyncTaskEnqueuerTest { @MockitoSettings(strictness = Strictness.LENIENT) @Test - void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() throws Exception { + void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() { ContactResource contact = persistActiveContact("jd23456"); asyncTaskEnqueuer.enqueueAsyncResave(contact, clock.nowUtc(), clock.nowUtc().plusDays(31)); assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS); diff --git a/core/src/test/java/google/registry/batch/DeleteContactsAndHostsActionTest.java b/core/src/test/java/google/registry/batch/DeleteContactsAndHostsActionTest.java index ee44bf4ef..aedaad5b4 100644 --- a/core/src/test/java/google/registry/batch/DeleteContactsAndHostsActionTest.java +++ b/core/src/test/java/google/registry/batch/DeleteContactsAndHostsActionTest.java @@ -476,7 +476,7 @@ public class DeleteContactsAndHostsActionTest } @Test - void testSuccess_targetResourcesDontExist_areDelayedForADay() throws Exception { + void testSuccess_targetResourcesDontExist_areDelayedForADay() { ContactResource contactNotSaved = newContactResource("somecontact"); HostResource hostNotSaved = newHostResource("a11.blah.foo"); DateTime timeBeforeRun = clock.nowUtc(); @@ -515,7 +515,7 @@ public class DeleteContactsAndHostsActionTest } @Test - void testSuccess_unparseableTasks_areDelayedForADay() throws Exception { + void testSuccess_unparseableTasks_areDelayedForADay() { TaskOptions task = TaskOptions.Builder.withMethod(Method.PULL).param("gobbledygook", "kljhadfgsd9f7gsdfh"); getQueue(QUEUE_ASYNC_DELETE).add(task); @@ -531,7 +531,7 @@ public class DeleteContactsAndHostsActionTest } @Test - void testSuccess_resourcesNotInPendingDelete_areSkipped() throws Exception { + void testSuccess_resourcesNotInPendingDelete_areSkipped() { ContactResource contact = persistActiveContact("blah2222"); HostResource host = persistActiveHost("rustles.your.jimmies"); DateTime timeEnqueued = clock.nowUtc(); @@ -563,7 +563,7 @@ public class DeleteContactsAndHostsActionTest } @Test - void testSuccess_alreadyDeletedResources_areSkipped() throws Exception { + void testSuccess_alreadyDeletedResources_areSkipped() { ContactResource contactDeleted = persistDeletedContact("blah1236", clock.nowUtc().minusDays(2)); HostResource hostDeleted = persistDeletedHost("a.lim.lop", clock.nowUtc().minusDays(3)); enqueuer.enqueueAsyncDelete( diff --git a/core/src/test/java/google/registry/batch/RefreshDnsOnHostRenameActionTest.java b/core/src/test/java/google/registry/batch/RefreshDnsOnHostRenameActionTest.java index bb09be42f..a23bb65b5 100644 --- a/core/src/test/java/google/registry/batch/RefreshDnsOnHostRenameActionTest.java +++ b/core/src/test/java/google/registry/batch/RefreshDnsOnHostRenameActionTest.java @@ -191,7 +191,7 @@ public class RefreshDnsOnHostRenameActionTest } @Test - void testRun_hostDoesntExist_delaysTask() throws Exception { + void testRun_hostDoesntExist_delaysTask() { HostResource host = newHostResource("ns1.example.tld"); enqueuer.enqueueAsyncDnsRefresh(host, clock.nowUtc()); enqueueMapreduceOnly(); @@ -222,7 +222,7 @@ public class RefreshDnsOnHostRenameActionTest } @Test - void test_noTasksToLease_releasesLockImmediately() throws Exception { + void test_noTasksToLease_releasesLockImmediately() { enqueueMapreduceOnly(); assertNoDnsTasksEnqueued(); assertNoTasksEnqueued(QUEUE_ASYNC_HOST_RENAME); diff --git a/core/src/test/java/google/registry/beam/initsql/BackupTestStore.java b/core/src/test/java/google/registry/beam/initsql/BackupTestStore.java index fdcb22717..c49e73b70 100644 --- a/core/src/test/java/google/registry/beam/initsql/BackupTestStore.java +++ b/core/src/test/java/google/registry/beam/initsql/BackupTestStore.java @@ -141,8 +141,7 @@ public final class BackupTestStore implements AutoCloseable { * to simulate an inconsistent export * @return directory where data is exported */ - File export( - String exportRootPath, Iterable> pojoTypes, Set> excludes) + File export(String exportRootPath, Iterable> pojoTypes, Set> excludes) throws IOException { File exportDirectory = getExportDirectory(exportRootPath); for (Class pojoType : pojoTypes) { diff --git a/core/src/test/java/google/registry/beam/initsql/BackupTestStoreTest.java b/core/src/test/java/google/registry/beam/initsql/BackupTestStoreTest.java index 0f9291b0d..d99d80621 100644 --- a/core/src/test/java/google/registry/beam/initsql/BackupTestStoreTest.java +++ b/core/src/test/java/google/registry/beam/initsql/BackupTestStoreTest.java @@ -44,8 +44,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collections; -import java.util.Set; import java.util.stream.Stream; import org.apache.beam.sdk.values.KV; import org.joda.time.DateTime; @@ -113,7 +111,7 @@ public class BackupTestStoreTest { assertWithMessage("Directory %s should not exist.", exportFolder.getAbsoluteFile()) .that(exportFolder.exists()) .isFalse(); - File actualExportFolder = export(exportRootPath, Collections.EMPTY_SET); + File actualExportFolder = export(exportRootPath, ImmutableSet.of()); assertThat(actualExportFolder).isEquivalentAccordingToCompareTo(exportFolder); try (Stream files = Files.walk(exportFolder.toPath()) @@ -136,14 +134,14 @@ public class BackupTestStoreTest { assertWithMessage("Directory %s should not exist.", exportFolder.getAbsoluteFile()) .that(exportFolder.exists()) .isFalse(); - assertThat(export(exportRootPath, Collections.EMPTY_SET)) + assertThat(export(exportRootPath, ImmutableSet.of())) .isEquivalentAccordingToCompareTo(exportFolder); } @Test void export_dataReadBack() throws IOException { String exportRootPath = tempDir.getAbsolutePath(); - File exportFolder = export(exportRootPath, Collections.EMPTY_SET); + File exportFolder = export(exportRootPath, ImmutableSet.of()); ImmutableList loadedRegistries = loadExportedEntities(new File(exportFolder, "/all_namespaces/kind_Registry/output-0")); assertThat(loadedRegistries).containsExactly(registry); @@ -228,7 +226,7 @@ public class BackupTestStoreTest { assertThat(CommitLogImports.loadEntities(commitLogFile)).isEmpty(); } - private File export(String exportRootPath, Set> excludes) throws IOException { + private File export(String exportRootPath, ImmutableSet> excludes) throws IOException { return store.export( exportRootPath, ImmutableList.of(ContactResource.class, DomainBase.class, Registry.class), diff --git a/core/src/test/java/google/registry/flows/EppTestCase.java b/core/src/test/java/google/registry/flows/EppTestCase.java index 9da13d4dc..42537c4ee 100644 --- a/core/src/test/java/google/registry/flows/EppTestCase.java +++ b/core/src/test/java/google/registry/flows/EppTestCase.java @@ -220,7 +220,7 @@ public class EppTestCase { return actualOutput; } - private FakeResponse executeXmlCommand(String inputXml) throws Exception { + private FakeResponse executeXmlCommand(String inputXml) { EppRequestHandler handler = new EppRequestHandler(); FakeResponse response = new FakeResponse(); handler.response = response; diff --git a/core/src/test/java/google/registry/flows/certs/CertificateCheckerTest.java b/core/src/test/java/google/registry/flows/certs/CertificateCheckerTest.java index f48b8a648..029c0cbb5 100644 --- a/core/src/test/java/google/registry/flows/certs/CertificateCheckerTest.java +++ b/core/src/test/java/google/registry/flows/certs/CertificateCheckerTest.java @@ -200,7 +200,7 @@ class CertificateCheckerTest { } @Test - void test_checkCertificate_validCertificateString() throws Exception { + void test_checkCertificate_validCertificateString() { fakeClock.setTo(DateTime.parse("2020-11-01T00:00:00Z")); assertThat(certificateChecker.checkCertificate(SAMPLE_CERT3)).isEmpty(); assertThat(certificateChecker.checkCertificate(SAMPLE_CERT)) @@ -208,7 +208,7 @@ class CertificateCheckerTest { } @Test - void test_checkCertificate_invalidCertificateString() throws Exception { + void test_checkCertificate_invalidCertificateString() { fakeClock.setTo(DateTime.parse("2020-11-01T00:00:00Z")); IllegalArgumentException thrown = assertThrows( diff --git a/core/src/test/java/google/registry/model/EntityTestCase.java b/core/src/test/java/google/registry/model/EntityTestCase.java index 7a368bfb7..da53b6a39 100644 --- a/core/src/test/java/google/registry/model/EntityTestCase.java +++ b/core/src/test/java/google/registry/model/EntityTestCase.java @@ -55,7 +55,7 @@ public abstract class EntityTestCase { */ ENABLED, /** The test is not relevant for JPA coverage checks. */ - DISABLED; + DISABLED } protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC)); diff --git a/core/src/test/java/google/registry/model/history/DomainHistoryTest.java b/core/src/test/java/google/registry/model/history/DomainHistoryTest.java index 6b46c677d..2d4c6c09d 100644 --- a/core/src/test/java/google/registry/model/history/DomainHistoryTest.java +++ b/core/src/test/java/google/registry/model/history/DomainHistoryTest.java @@ -20,6 +20,7 @@ import static google.registry.model.ImmutableObjectSubject.immutableObjectCorres import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; +import static google.registry.testing.AppEngineExtension.makeRegistrar2; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.newContactResourceWithRoid; import static google.registry.testing.DatabaseHelper.newDomainBase; @@ -42,7 +43,6 @@ import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.Trid; import google.registry.model.host.HostResource; -import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registries; import google.registry.model.registry.Registry; import google.registry.model.reporting.DomainTransactionRecord; @@ -144,13 +144,9 @@ public class DomainHistoryTest extends EntityTestCase { .transact( () -> { jpaTm().insert(registry); - Registrar registrar = - appEngine - .makeRegistrar2() - .asBuilder() - .setAllowedTlds(ImmutableSet.of("tld")) - .build(); - jpaTm().insert(registrar); + jpaTm() + .insert( + makeRegistrar2().asBuilder().setAllowedTlds(ImmutableSet.of("tld")).build()); }); HostResource host = newHostResourceWithRoid("ns1.example.com", "host1"); diff --git a/core/src/test/java/google/registry/model/registry/RegistryTest.java b/core/src/test/java/google/registry/model/registry/RegistryTest.java index 04331b4a2..6d58fc262 100644 --- a/core/src/test/java/google/registry/model/registry/RegistryTest.java +++ b/core/src/test/java/google/registry/model/registry/RegistryTest.java @@ -54,7 +54,7 @@ import org.junit.jupiter.api.BeforeEach; /** Unit tests for {@link Registry}. */ @DualDatabaseTest -public class RegistryTest extends EntityTestCase { +public final class RegistryTest extends EntityTestCase { RegistryTest() { super(JpaEntityCoverageCheck.ENABLED); @@ -66,7 +66,7 @@ public class RegistryTest extends EntityTestCase { } @TestOfyAndSql - public void testPersistence_updateReservedAndPremiumListSuccessfully() { + void testPersistence_updateReservedAndPremiumListSuccessfully() { ReservedList rl15 = persistReservedList("tld-reserved15", "potato,FULLY_BLOCKED"); PremiumList pl = persistPremiumList("tld2", "lol,USD 50", "cat,USD 700"); Registry registry = diff --git a/core/src/test/java/google/registry/model/reporting/HistoryEntryDaoTest.java b/core/src/test/java/google/registry/model/reporting/HistoryEntryDaoTest.java index 44c1c849b..788a0f055 100644 --- a/core/src/test/java/google/registry/model/reporting/HistoryEntryDaoTest.java +++ b/core/src/test/java/google/registry/model/reporting/HistoryEntryDaoTest.java @@ -38,7 +38,7 @@ import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; @DualDatabaseTest -public class HistoryEntryDaoTest extends EntityTestCase { +class HistoryEntryDaoTest extends EntityTestCase { private DomainBase domain; private HistoryEntry historyEntry; diff --git a/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchDaoTest.java b/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchDaoTest.java index b7ec4a490..d841ea387 100644 --- a/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchDaoTest.java +++ b/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchDaoTest.java @@ -35,7 +35,7 @@ import org.junit.jupiter.api.BeforeEach; /** Unit tests for {@link Spec11ThreatMatchDao}. */ @DualDatabaseTest -public class Spec11ThreatMatchDaoTest extends EntityTestCase { +class Spec11ThreatMatchDaoTest extends EntityTestCase { private static final LocalDate TODAY = new LocalDate(2020, 8, 4); private static final LocalDate YESTERDAY = new LocalDate(2020, 8, 3); diff --git a/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchTest.java b/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchTest.java index b89e94655..3a446f41f 100644 --- a/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchTest.java +++ b/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchTest.java @@ -40,7 +40,7 @@ import org.junit.jupiter.api.Disabled; /** Unit tests for {@link Spec11ThreatMatch}. */ @DualDatabaseTest -public class Spec11ThreatMatchTest extends EntityTestCase { +public final class Spec11ThreatMatchTest extends EntityTestCase { private static final String REGISTRAR_ID = "registrar"; private static final LocalDate DATE = LocalDate.parse("2020-06-10", ISODateTimeFormat.date()); diff --git a/core/src/test/java/google/registry/persistence/EntityCallbacksListenerTest.java b/core/src/test/java/google/registry/persistence/EntityCallbacksListenerTest.java index ab4d2084a..2c9453af1 100644 --- a/core/src/test/java/google/registry/persistence/EntityCallbacksListenerTest.java +++ b/core/src/test/java/google/registry/persistence/EntityCallbacksListenerTest.java @@ -82,7 +82,7 @@ class EntityCallbacksListenerTest { @Test void verifyAllManagedEntities_haveNoMethodWithEmbedded() { - ImmutableSet violations = + ImmutableSet> violations = PersistenceXmlUtility.getManagedClasses().stream() .filter(clazz -> clazz.isAnnotationPresent(Entity.class)) .filter(EntityCallbacksListenerTest::hasMethodAnnotatedWithEmbedded) diff --git a/core/src/test/java/google/registry/persistence/PersistenceXmlTest.java b/core/src/test/java/google/registry/persistence/PersistenceXmlTest.java index 2d48a914a..fce5f7b3e 100644 --- a/core/src/test/java/google/registry/persistence/PersistenceXmlTest.java +++ b/core/src/test/java/google/registry/persistence/PersistenceXmlTest.java @@ -30,19 +30,19 @@ class PersistenceXmlTest { @Test void verifyClassTags_containOnlyRequiredClasses() { - ImmutableList managedClassed = PersistenceXmlUtility.getManagedClasses(); + ImmutableList> managedClasses = PersistenceXmlUtility.getManagedClasses(); - ImmutableList unnecessaryClasses = - managedClassed.stream() + ImmutableList> unnecessaryClasses = + managedClasses.stream() .filter( clazz -> !clazz.isAnnotationPresent(Entity.class) && !AttributeConverter.class.isAssignableFrom(clazz)) .collect(toImmutableList()); - ImmutableSet duplicateClasses = - managedClassed.stream() - .filter(clazz -> Collections.frequency(managedClassed, clazz) > 1) + ImmutableSet> duplicateClasses = + managedClasses.stream() + .filter(clazz -> Collections.frequency(managedClasses, clazz) > 1) .collect(toImmutableSet()); assertWithMessage("Found duplicate tags defined in persistence.xml.") diff --git a/core/src/test/java/google/registry/persistence/converter/LocalDateConverterTest.java b/core/src/test/java/google/registry/persistence/converter/LocalDateConverterTest.java index cbc529017..9bc913b51 100644 --- a/core/src/test/java/google/registry/persistence/converter/LocalDateConverterTest.java +++ b/core/src/test/java/google/registry/persistence/converter/LocalDateConverterTest.java @@ -55,11 +55,9 @@ public class LocalDateConverterTest { private LocalDateConverterTestEntity persistAndLoadTestEntity(LocalDate date) { LocalDateConverterTestEntity entity = new LocalDateConverterTestEntity(date); jpaTm().transact(() -> jpaTm().insert(entity)); - LocalDateConverterTestEntity retrievedEntity = - jpaTm() - .transact( - () -> jpaTm().loadByKey(VKey.createSql(LocalDateConverterTestEntity.class, "id"))); - return retrievedEntity; + return jpaTm() + .transact( + () -> jpaTm().loadByKey(VKey.createSql(LocalDateConverterTestEntity.class, "id"))); } /** Override entity name to avoid the nested class reference. */ diff --git a/core/src/test/java/google/registry/persistence/transaction/JpaEntityCoverageExtension.java b/core/src/test/java/google/registry/persistence/transaction/JpaEntityCoverageExtension.java index c72203b29..7790683b5 100644 --- a/core/src/test/java/google/registry/persistence/transaction/JpaEntityCoverageExtension.java +++ b/core/src/test/java/google/registry/persistence/transaction/JpaEntityCoverageExtension.java @@ -50,13 +50,13 @@ public class JpaEntityCoverageExtension implements BeforeEachCallback, AfterEach // TransactionEntity is trivial, its persistence is tested in TransactionTest. "TransactionEntity"); - private static final ImmutableSet ALL_JPA_ENTITIES = + private static final ImmutableSet> ALL_JPA_ENTITIES = PersistenceXmlUtility.getManagedClasses().stream() .filter(e -> !IGNORE_ENTITIES.contains(e.getSimpleName())) .filter(e -> e.isAnnotationPresent(Entity.class)) .filter(e -> !e.isAnnotationPresent(DiscriminatorValue.class)) .collect(ImmutableSet.toImmutableSet()); - private static final Set allCoveredJpaEntities = Sets.newHashSet(); + private static final Set> allCoveredJpaEntities = Sets.newHashSet(); // Map of test class name to boolean flag indicating if it tests any JPA entities. private static final Map testsJpaEntities = Maps.newHashMap(); @@ -81,7 +81,7 @@ public class JpaEntityCoverageExtension implements BeforeEachCallback, AfterEach testsJpaEntities.clear(); } - public static Set getUncoveredEntities() { + public static Set> getUncoveredEntities() { return Sets.difference(ALL_JPA_ENTITIES, allCoveredJpaEntities); } @@ -99,9 +99,9 @@ public class JpaEntityCoverageExtension implements BeforeEachCallback, AfterEach * * @return true if an instance of {@code entityType} is found in the database and can be read */ - private static boolean isPersisted(Class entityType) { + private static boolean isPersisted(Class entityType) { try { - List result = + List result = jpaTm() .transact( () -> diff --git a/core/src/test/java/google/registry/persistence/transaction/JpaTestRules.java b/core/src/test/java/google/registry/persistence/transaction/JpaTestRules.java index 2842d612f..ce12a7d83 100644 --- a/core/src/test/java/google/registry/persistence/transaction/JpaTestRules.java +++ b/core/src/test/java/google/registry/persistence/transaction/JpaTestRules.java @@ -49,7 +49,7 @@ public class JpaTestRules { public static class JpaIntegrationTestExtension extends JpaTransactionManagerExtension { private JpaIntegrationTestExtension( Clock clock, - ImmutableList extraEntityClasses, + ImmutableList> extraEntityClasses, ImmutableMap userProperties) { super(clock, Optional.of(GOLDEN_SCHEMA_SQL_PATH), extraEntityClasses, userProperties); } @@ -63,7 +63,7 @@ public class JpaTestRules { private JpaUnitTestExtension( Clock clock, Optional initScriptPath, - ImmutableList extraEntityClasses, + ImmutableList> extraEntityClasses, ImmutableMap userProperties) { super(clock, initScriptPath, false, extraEntityClasses, userProperties); } @@ -105,8 +105,8 @@ public class JpaTestRules { private String initScript; private Clock clock; - private List extraEntityClasses = new ArrayList(); - private Map userProperties = new HashMap(); + private List> extraEntityClasses = new ArrayList<>(); + private Map userProperties = new HashMap<>(); /** * Sets the SQL script to be used to initialize the database. If not set, @@ -125,7 +125,7 @@ public class JpaTestRules { } /** Adds annotated class(es) to the known entities for the database. */ - public Builder withEntityClass(Class... classes) { + public Builder withEntityClass(Class... classes) { this.extraEntityClasses.addAll(ImmutableSet.copyOf(classes)); return this; } diff --git a/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerExtension.java b/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerExtension.java index 40d63e4d1..c4b649cf5 100644 --- a/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerExtension.java +++ b/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerExtension.java @@ -87,8 +87,8 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft private final Clock clock; private final Optional initScriptPath; - private final ImmutableList extraEntityClasses; - private final ImmutableMap userProperties; + private final ImmutableList> extraEntityClasses; + private final ImmutableMap userProperties; private static final JdbcDatabaseContainer database = create(); private static final HibernateSchemaExporter exporter = @@ -102,7 +102,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft private JpaTransactionManager cachedTm; // Hash of the ORM entity names requested by this rule instance. - private int entityHash; + private final int entityHash; // Whether to create nomulus tables in the test db. Right now, only the JpaTestRules set this to // false. @@ -112,7 +112,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft Clock clock, Optional initScriptPath, boolean includeNomulusSchema, - ImmutableList extraEntityClasses, + ImmutableList> extraEntityClasses, ImmutableMap userProperties) { this.clock = clock; this.initScriptPath = initScriptPath; @@ -125,7 +125,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft JpaTransactionManagerExtension( Clock clock, Optional initScriptPath, - ImmutableList extraEntityClasses, + ImmutableList> extraEntityClasses, ImmutableMap userProperties) { this.clock = clock; this.initScriptPath = initScriptPath; @@ -143,7 +143,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft } private static int getOrmEntityHash( - Optional initScriptPath, ImmutableList extraEntityClasses) { + Optional initScriptPath, ImmutableList> extraEntityClasses) { return Streams.concat( Stream.of(initScriptPath.orElse("")), extraEntityClasses.stream().map(Class::getCanonicalName)) @@ -172,7 +172,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft executeSql(new String(Files.readAllBytes(tempSqlFile.toPath()), StandardCharsets.UTF_8)); } - ImmutableMap properties = PersistenceModule.provideDefaultDatabaseConfigs(); + ImmutableMap properties = PersistenceModule.provideDefaultDatabaseConfigs(); if (!userProperties.isEmpty()) { // If there are user properties, create a new properties object with these added. Map mergedProperties = Maps.newHashMap(); @@ -338,7 +338,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft return Bootstrap.getEntityManagerFactoryBuilder(descriptor, properties).build(); } - private ImmutableList getTestEntities() { + private ImmutableList> getTestEntities() { // We have to add the TransactionEntity to extra entities, as this is required by the // transaction replication mechanism. return Stream.concat(extraEntityClasses.stream(), Stream.of(TransactionEntity.class)) diff --git a/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerImplTest.java b/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerImplTest.java index 5555771a0..b2c3a71f1 100644 --- a/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerImplTest.java +++ b/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerImplTest.java @@ -180,7 +180,7 @@ class JpaTransactionManagerImplTest { @Test void transact_retriesNestedOptimisticLockExceptions() { JpaTransactionManager spyJpaTm = spy(jpaTm()); - doThrow(new RuntimeException().initCause(new OptimisticLockException())) + doThrow(new RuntimeException(new OptimisticLockException())) .when(spyJpaTm) .delete(any(VKey.class)); spyJpaTm.transact(() -> spyJpaTm.insert(theEntity)); @@ -220,8 +220,8 @@ class JpaTransactionManagerImplTest { void transactNewReadOnly_retriesNestedJdbcConnectionExceptions() { JpaTransactionManager spyJpaTm = spy(jpaTm()); doThrow( - new RuntimeException() - .initCause(new JDBCConnectionException("connection exception", new SQLException()))) + new RuntimeException( + new JDBCConnectionException("connection exception", new SQLException()))) .when(spyJpaTm) .loadByKey(any(VKey.class)); spyJpaTm.transact(() -> spyJpaTm.insert(theEntity)); diff --git a/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerRuleTest.java b/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerRuleTest.java index 1b68f7d26..dfa784b51 100644 --- a/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerRuleTest.java +++ b/core/src/test/java/google/registry/persistence/transaction/JpaTransactionManagerRuleTest.java @@ -52,7 +52,7 @@ public class JpaTransactionManagerRuleTest { jpaTm() .transact( () -> { - List results = + List results = jpaTm() .getEntityManager() .createNativeQuery("SELECT * FROM \"TestEntity\"") diff --git a/core/src/test/java/google/registry/privileges/secretmanager/SecretManagerClientTest.java b/core/src/test/java/google/registry/privileges/secretmanager/SecretManagerClientTest.java index 94ea98f0d..3d38027dc 100644 --- a/core/src/test/java/google/registry/privileges/secretmanager/SecretManagerClientTest.java +++ b/core/src/test/java/google/registry/privileges/secretmanager/SecretManagerClientTest.java @@ -78,7 +78,7 @@ public class SecretManagerClientTest { } @AfterEach - void afterEach() throws IOException { + void afterEach() { if (isUnitTest) { return; } diff --git a/core/src/test/java/google/registry/reporting/icann/IcannHttpReporterTest.java b/core/src/test/java/google/registry/reporting/icann/IcannHttpReporterTest.java index c455b45dd..86b5c3afc 100644 --- a/core/src/test/java/google/registry/reporting/icann/IcannHttpReporterTest.java +++ b/core/src/test/java/google/registry/reporting/icann/IcannHttpReporterTest.java @@ -130,7 +130,7 @@ class IcannHttpReporterTest { } @Test - void testFail_transportException() throws Exception { + void testFail_transportException() { IcannHttpReporter reporter = createReporter(); reporter.httpTransport = createMockTransport(HttpStatusCodes.STATUS_CODE_FORBIDDEN, ByteSource.empty()); diff --git a/core/src/test/java/google/registry/schema/server/LockDaoTest.java b/core/src/test/java/google/registry/schema/server/LockDaoTest.java index d8ce61e7d..c833a00b0 100644 --- a/core/src/test/java/google/registry/schema/server/LockDaoTest.java +++ b/core/src/test/java/google/registry/schema/server/LockDaoTest.java @@ -154,8 +154,7 @@ public class LockDaoTest { assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( - Level.WARNING, - String.format("Cloud SQL lock for testResource with tld GLOBAL should be null")); + Level.WARNING, "Cloud SQL lock for testResource with tld GLOBAL should be null"); } @Test @@ -171,22 +170,19 @@ public class LockDaoTest { .that(logHandler) .hasLogAtLevelWithMessage( Level.WARNING, - String.format( - "Datastore lock requestLogId of wrong does not equal Cloud SQL lock requestLogId" - + " of testLogId")); + "Datastore lock requestLogId of wrong does not equal Cloud SQL lock requestLogId" + + " of testLogId"); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.WARNING, - String.format( - "Datastore lock acquiredTime of 1969-12-31T00:00:00.000Z does not equal Cloud SQL" - + " lock acquiredTime of 1970-01-01T00:00:00.000Z")); + "Datastore lock acquiredTime of 1969-12-31T00:00:00.000Z does not equal Cloud SQL" + + " lock acquiredTime of 1970-01-01T00:00:00.000Z"); assertAboutLogs() .that(logHandler) .hasLogAtLevelWithMessage( Level.WARNING, - String.format( - "Datastore lock expirationTime of 1969-12-31T00:00:00.003Z does not equal Cloud" - + " SQL lock expirationTime of 1970-01-01T00:00:00.002Z")); + "Datastore lock expirationTime of 1969-12-31T00:00:00.003Z does not equal Cloud" + + " SQL lock expirationTime of 1970-01-01T00:00:00.002Z"); } } diff --git a/core/src/test/java/google/registry/testing/AppEngineExtension.java b/core/src/test/java/google/registry/testing/AppEngineExtension.java index 909f4d74d..49bad0839 100644 --- a/core/src/test/java/google/registry/testing/AppEngineExtension.java +++ b/core/src/test/java/google/registry/testing/AppEngineExtension.java @@ -381,9 +381,7 @@ public final class AppEngineExtension implements BeforeEachCallback, AfterEachCa jpaIntegrationWithCoverageExtension.beforeEach(context); } else if (withJpaUnitTest) { jpaUnitTestRule = - builder - .withEntityClass(jpaTestEntities.toArray(new Class[jpaTestEntities.size()])) - .buildUnitTestRule(); + builder.withEntityClass(jpaTestEntities.toArray(new Class[0])).buildUnitTestRule(); jpaUnitTestRule.beforeEach(context); } else { jpaIntegrationTestRule = builder.buildIntegrationTestRule(); diff --git a/core/src/test/java/google/registry/testing/ContextCapturingMetaExtension.java b/core/src/test/java/google/registry/testing/ContextCapturingMetaExtension.java index 46d048360..94489a7f3 100644 --- a/core/src/test/java/google/registry/testing/ContextCapturingMetaExtension.java +++ b/core/src/test/java/google/registry/testing/ContextCapturingMetaExtension.java @@ -31,7 +31,7 @@ public class ContextCapturingMetaExtension implements BeforeEachCallback { private ExtensionContext context; @Override - public void beforeEach(ExtensionContext context) throws Exception { + public void beforeEach(ExtensionContext context) { this.context = context; } diff --git a/core/src/test/java/google/registry/tools/CreateCdnsTldTest.java b/core/src/test/java/google/registry/tools/CreateCdnsTldTest.java index 1a6bab409..bb6f0867e 100644 --- a/core/src/test/java/google/registry/tools/CreateCdnsTldTest.java +++ b/core/src/test/java/google/registry/tools/CreateCdnsTldTest.java @@ -76,7 +76,7 @@ class CreateCdnsTldTest extends CommandTestCase { @Test @MockitoSettings(strictness = Strictness.LENIENT) - void testSandboxTldRestrictions() throws Exception { + void testSandboxTldRestrictions() { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, diff --git a/core/src/test/java/google/registry/tools/CreateRegistrarCommandTest.java b/core/src/test/java/google/registry/tools/CreateRegistrarCommandTest.java index 78b6f2d4f..3f6b59537 100644 --- a/core/src/test/java/google/registry/tools/CreateRegistrarCommandTest.java +++ b/core/src/test/java/google/registry/tools/CreateRegistrarCommandTest.java @@ -365,7 +365,7 @@ class CreateRegistrarCommandTest extends CommandTestCase } @Test - void testFail_clientCertFileFlagWithViolation() throws Exception { + void testFail_clientCertFileFlagWithViolation() { fakeClock.setTo(DateTime.parse("2020-10-01T00:00:00Z")); InsecureCertificateException thrown = assertThrows( @@ -395,7 +395,7 @@ class CreateRegistrarCommandTest extends CommandTestCase } @Test - void testFail_clientCertFileFlagWithMultipleViolations() throws Exception { + void testFail_clientCertFileFlagWithMultipleViolations() { fakeClock.setTo(DateTime.parse("2055-10-01T00:00:00Z")); InsecureCertificateException thrown = assertThrows( @@ -452,7 +452,7 @@ class CreateRegistrarCommandTest extends CommandTestCase } @Test - void testFail_failoverClientCertFileFlagWithViolations() throws Exception { + void testFail_failoverClientCertFileFlagWithViolations() { fakeClock.setTo(DateTime.parse("2020-11-01T00:00:00Z")); InsecureCertificateException thrown = assertThrows( @@ -482,7 +482,7 @@ class CreateRegistrarCommandTest extends CommandTestCase } @Test - void testFail_failoverClientCertFileFlagWithMultipleViolations() throws Exception { + void testFail_failoverClientCertFileFlagWithMultipleViolations() { fakeClock.setTo(DateTime.parse("2055-11-01T00:00:00Z")); InsecureCertificateException thrown = assertThrows( diff --git a/core/src/test/java/google/registry/tools/CurlCommandTest.java b/core/src/test/java/google/registry/tools/CurlCommandTest.java index d3bebea77..e16c8ab8a 100644 --- a/core/src/test/java/google/registry/tools/CurlCommandTest.java +++ b/core/src/test/java/google/registry/tools/CurlCommandTest.java @@ -101,7 +101,7 @@ class CurlCommandTest extends CommandTestCase { @Test @MockitoSettings(strictness = Strictness.LENIENT) - void testPostInvocation_badContentType() throws Exception { + void testPostInvocation_badContentType() { assertThrows( IllegalArgumentException.class, () -> diff --git a/core/src/test/java/google/registry/tools/DedupeOneTimeBillingEventIdsCommandTest.java b/core/src/test/java/google/registry/tools/DedupeOneTimeBillingEventIdsCommandTest.java index 85cbf461b..440936ccb 100644 --- a/core/src/test/java/google/registry/tools/DedupeOneTimeBillingEventIdsCommandTest.java +++ b/core/src/test/java/google/registry/tools/DedupeOneTimeBillingEventIdsCommandTest.java @@ -80,7 +80,7 @@ class DedupeOneTimeBillingEventIdsCommandTest } @Test - void resaveBillingEvent_failsWhenReferredByDomain() throws Exception { + void resaveBillingEvent_failsWhenReferredByDomain() { persistResource( domain .asBuilder() diff --git a/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java b/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java index c7c496944..38c974a2a 100644 --- a/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java +++ b/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java @@ -115,7 +115,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase runCommand(one.toString(), two.toString())); diff --git a/core/src/test/java/google/registry/tools/ShellCommandTest.java b/core/src/test/java/google/registry/tools/ShellCommandTest.java index 4dd2b0132..62ba58cee 100644 --- a/core/src/test/java/google/registry/tools/ShellCommandTest.java +++ b/core/src/test/java/google/registry/tools/ShellCommandTest.java @@ -266,8 +266,7 @@ class ShellCommandTest { @Test void testEncapsulatedOutputStream_emptyStream() { ByteArrayOutputStream backing = new ByteArrayOutputStream(); - try (PrintStream out = - new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: "))) {} + new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: ")).close(); assertThat(backing.toString()).isEqualTo(""); } diff --git a/core/src/test/java/google/registry/tools/params/PathParameterTest.java b/core/src/test/java/google/registry/tools/params/PathParameterTest.java index 644137b2f..6208edcc6 100644 --- a/core/src/test/java/google/registry/tools/params/PathParameterTest.java +++ b/core/src/test/java/google/registry/tools/params/PathParameterTest.java @@ -54,7 +54,7 @@ class PathParameterTest { } @Test - void testConvert_relativePath_returnsOriginalFile() throws Exception { + void testConvert_relativePath_returnsOriginalFile() { Path currentDirectory = Paths.get("").toAbsolutePath(); Path file = Paths.get(tmpDir.resolve("tmp.file").toString()); Path relative = file.relativize(currentDirectory); @@ -65,7 +65,7 @@ class PathParameterTest { } @Test - void testConvert_extraSlash_returnsWithoutSlash() throws Exception { + void testConvert_extraSlash_returnsWithoutSlash() { Path file = Paths.get(tmpDir.resolve("file.new").toString()); assertThat((Object) vanilla.convert(file + "/")).isEqualTo(file); } @@ -115,7 +115,7 @@ class PathParameterTest { private final PathParameter outputFile = new PathParameter.OutputFile(); @Test - void testOutputFileValidate_normalFile_works() throws Exception { + void testOutputFileValidate_normalFile_works() { outputFile.validate("input", tmpDir.resolve("testfile").toString()); } diff --git a/core/src/test/java/google/registry/ui/server/registrar/SecuritySettingsTest.java b/core/src/test/java/google/registry/ui/server/registrar/SecuritySettingsTest.java index 53b9cdcfd..322f9dc7d 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/SecuritySettingsTest.java +++ b/core/src/test/java/google/registry/ui/server/registrar/SecuritySettingsTest.java @@ -146,7 +146,7 @@ class SecuritySettingsTest extends RegistrarSettingsActionTestCase { } @Test - void testEmptyOrNullCertificate_doesNotClearOutCurrentOne() throws Exception { + void testEmptyOrNullCertificate_doesNotClearOutCurrentOne() { Registrar initialRegistrar = persistResource( loadRegistrar(CLIENT_ID) diff --git a/docs/src/test/java/google/registry/documentation/FlowDocumentationTest.java b/docs/src/test/java/google/registry/documentation/FlowDocumentationTest.java index 275af4457..bca9affd8 100644 --- a/docs/src/test/java/google/registry/documentation/FlowDocumentationTest.java +++ b/docs/src/test/java/google/registry/documentation/FlowDocumentationTest.java @@ -16,7 +16,6 @@ package google.registry.documentation; import static com.google.common.truth.Truth.assertWithMessage; import static google.registry.util.BuildPathUtils.getProjectRoot; -import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.base.Joiner; import java.nio.file.Files; @@ -41,9 +40,7 @@ class FlowDocumentationTest { @Test void testGeneratedMatchesGolden() throws Exception { // Read the markdown file. - Path goldenMarkdownPath = GOLDEN_MARKDOWN_FILEPATH; - - String goldenMarkdown = new String(Files.readAllBytes(goldenMarkdownPath), UTF_8); + String goldenMarkdown = Files.readString(GOLDEN_MARKDOWN_FILEPATH); // Don't use Truth's isEqualTo() because the output is huge and unreadable for large files. DocumentationGenerator generator = new DocumentationGenerator(); diff --git a/networking/src/test/java/google/registry/networking/handler/NettyExtension.java b/networking/src/test/java/google/registry/networking/handler/NettyExtension.java index 55a39a64a..1f8187022 100644 --- a/networking/src/test/java/google/registry/networking/handler/NettyExtension.java +++ b/networking/src/test/java/google/registry/networking/handler/NettyExtension.java @@ -101,7 +101,7 @@ public final class NettyExtension implements AfterEachCallback { ChannelInitializer clientInitializer = new ChannelInitializer() { @Override - protected void initChannel(LocalChannel ch) throws Exception { + protected void initChannel(LocalChannel ch) { // Add the given handler ch.pipeline().addLast(handler); // Add the "dumpHandler" last to log the incoming message @@ -178,7 +178,7 @@ public final class NettyExtension implements AfterEachCallback { } @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + public void channelRead(ChannelHandlerContext ctx, Object msg) { // In the test we only send messages of type ByteBuf. assertThat(msg).isInstanceOf(ByteBuf.class); String request = ((ByteBuf) msg).toString(UTF_8); @@ -189,7 +189,7 @@ public final class NettyExtension implements AfterEachCallback { /** Saves any inbound error as the cause of the promise failure. */ @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { ChannelFuture unusedFuture = ctx.channel().closeFuture().addListener(f -> requestFuture.completeExceptionally(cause)); } @@ -205,7 +205,7 @@ public final class NettyExtension implements AfterEachCallback { } @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + public void channelRead(ChannelHandlerContext ctx, Object msg) { // In the test we only send messages of type ByteBuf. assertThat(msg).isInstanceOf(ByteBuf.class); String response = ((ByteBuf) msg).toString(UTF_8); @@ -218,7 +218,7 @@ public final class NettyExtension implements AfterEachCallback { /** Saves any inbound error into the failure cause of the promise. */ @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { ctx.channel().closeFuture().addListener(f -> responseFuture.completeExceptionally(cause)); } } diff --git a/prober/src/main/java/google/registry/monitoring/blackbox/connection/ProbingAction.java b/prober/src/main/java/google/registry/monitoring/blackbox/connection/ProbingAction.java index e3dac553f..f0affc304 100644 --- a/prober/src/main/java/google/registry/monitoring/blackbox/connection/ProbingAction.java +++ b/prober/src/main/java/google/registry/monitoring/blackbox/connection/ProbingAction.java @@ -270,7 +270,7 @@ public abstract class ProbingAction implements Callable { .handler( new ChannelInitializer() { @Override - protected void initChannel(Channel outboundChannel) throws Exception { + protected void initChannel(Channel outboundChannel) { // Uses Handlers from Protocol to fill pipeline in order of provided handlers. for (Provider handlerProvider : protocol().handlerProviders()) { diff --git a/prober/src/main/java/google/registry/monitoring/blackbox/message/EppMessage.java b/prober/src/main/java/google/registry/monitoring/blackbox/message/EppMessage.java index 7e4892b24..346d24910 100644 --- a/prober/src/main/java/google/registry/monitoring/blackbox/message/EppMessage.java +++ b/prober/src/main/java/google/registry/monitoring/blackbox/message/EppMessage.java @@ -414,7 +414,7 @@ public class EppMessage { } } - void addNamespace(String prefix, String namespaceURI) throws Exception { + void addNamespace(String prefix, String namespaceURI) { checkArgument(!isNullOrEmpty(prefix), "prefix"); checkArgument(!isNullOrEmpty(namespaceURI), "namespaceURI"); if (nsPrefixMap.containsKey(prefix)) { diff --git a/proxy/src/main/java/google/registry/proxy/ProxyServer.java b/proxy/src/main/java/google/registry/proxy/ProxyServer.java index d33428e10..8d0ea1357 100644 --- a/proxy/src/main/java/google/registry/proxy/ProxyServer.java +++ b/proxy/src/main/java/google/registry/proxy/ProxyServer.java @@ -84,7 +84,7 @@ public class ProxyServer implements Runnable { */ private static class ServerChannelInitializer extends ChannelInitializer { @Override - protected void initChannel(NioSocketChannel inboundChannel) throws Exception { + protected void initChannel(NioSocketChannel inboundChannel) { // Add inbound channel handlers. FrontendProtocol inboundProtocol = (FrontendProtocol) inboundChannel.parent().attr(PROTOCOL_KEY).get(); @@ -110,8 +110,7 @@ public class ProxyServer implements Runnable { .handler( new ChannelInitializer() { @Override - protected void initChannel(NioSocketChannel outboundChannel) - throws Exception { + protected void initChannel(NioSocketChannel outboundChannel) { addHandlers( outboundChannel.pipeline(), outboundProtocol.handlerProviders()); } @@ -301,7 +300,7 @@ public class ProxyServer implements Runnable { } } - public static void main(String[] args) throws Exception { + public static void main(String[] args) { // Use JDK logger for Netty's LoggingHandler, // which is what Flogger uses under the hood. InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.INSTANCE); diff --git a/proxy/src/main/java/google/registry/proxy/handler/BackendMetricsHandler.java b/proxy/src/main/java/google/registry/proxy/handler/BackendMetricsHandler.java index 236258db2..e19bdf83f 100644 --- a/proxy/src/main/java/google/registry/proxy/handler/BackendMetricsHandler.java +++ b/proxy/src/main/java/google/registry/proxy/handler/BackendMetricsHandler.java @@ -102,8 +102,7 @@ public class BackendMetricsHandler extends ChannelDuplexHandler { } @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) - throws Exception { + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { checkArgument(msg instanceof FullHttpRequest, "Outgoing request must be FullHttpRequest."); // For WHOIS, client certificate hash is always set to "none". // For EPP, the client hash attribute is set upon handshake completion, before the first HELLO diff --git a/proxy/src/main/java/google/registry/proxy/handler/FrontendMetricsHandler.java b/proxy/src/main/java/google/registry/proxy/handler/FrontendMetricsHandler.java index 582c0c6e1..0fd84c024 100644 --- a/proxy/src/main/java/google/registry/proxy/handler/FrontendMetricsHandler.java +++ b/proxy/src/main/java/google/registry/proxy/handler/FrontendMetricsHandler.java @@ -88,8 +88,7 @@ public class FrontendMetricsHandler extends ChannelDuplexHandler { } @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) - throws Exception { + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) { // Only instrument request metrics when the response is actually sent to client. // It is OK to check the queue size preemptively here, not when the front element of the queue // is acutally removed after the write to the client is successful, because responses are diff --git a/proxy/src/main/java/google/registry/proxy/handler/HealthCheckHandler.java b/proxy/src/main/java/google/registry/proxy/handler/HealthCheckHandler.java index 38f767ed3..06cb1c0c0 100644 --- a/proxy/src/main/java/google/registry/proxy/handler/HealthCheckHandler.java +++ b/proxy/src/main/java/google/registry/proxy/handler/HealthCheckHandler.java @@ -33,7 +33,7 @@ public class HealthCheckHandler extends ChannelInboundHandlerAdapter { } @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + public void channelRead(ChannelHandlerContext ctx, Object msg) { ByteBuf buf = (ByteBuf) msg; if (buf.equals(checkRequest)) { ChannelFuture unusedFuture = ctx.writeAndFlush(checkResponse); diff --git a/proxy/src/main/java/google/registry/proxy/handler/HttpsRelayServiceHandler.java b/proxy/src/main/java/google/registry/proxy/handler/HttpsRelayServiceHandler.java index 4a8d6a5c7..1461875d5 100644 --- a/proxy/src/main/java/google/registry/proxy/handler/HttpsRelayServiceHandler.java +++ b/proxy/src/main/java/google/registry/proxy/handler/HttpsRelayServiceHandler.java @@ -125,8 +125,7 @@ public abstract class HttpsRelayServiceHandler extends ByteToMessageCodec out) - throws Exception { + protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List out) { FullHttpRequest request = decodeFullHttpRequest(byteBuf); loadCookies(request); out.add(request); @@ -169,7 +168,7 @@ public abstract class HttpsRelayServiceHandler extends ByteToMessageCodec out) throws Exception { + protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) { // Wait until there are more bytes available than the header's length before processing. if (in.readableBytes() >= HEADER_PREFIX.length) { if (containsHeader(in)) { diff --git a/proxy/src/main/java/google/registry/proxy/handler/RelayHandler.java b/proxy/src/main/java/google/registry/proxy/handler/RelayHandler.java index 3da0740c7..bd9c3fed3 100644 --- a/proxy/src/main/java/google/registry/proxy/handler/RelayHandler.java +++ b/proxy/src/main/java/google/registry/proxy/handler/RelayHandler.java @@ -62,7 +62,7 @@ public class RelayHandler extends SimpleChannelInboundHandler { /** Read message of type {@code I}, write it as-is into the relay channel. */ @Override - protected void channelRead0(ChannelHandlerContext ctx, I msg) throws Exception { + protected void channelRead0(ChannelHandlerContext ctx, I msg) { Channel channel = ctx.channel(); Channel relayChannel = channel.attr(RELAY_CHANNEL_KEY).get(); if (relayChannel == null) { diff --git a/proxy/src/test/java/google/registry/proxy/ProtocolModuleTest.java b/proxy/src/test/java/google/registry/proxy/ProtocolModuleTest.java index 01fe1352f..c17e03067 100644 --- a/proxy/src/test/java/google/registry/proxy/ProtocolModuleTest.java +++ b/proxy/src/test/java/google/registry/proxy/ProtocolModuleTest.java @@ -154,7 +154,7 @@ public abstract class ProtocolModuleTest { new EmbeddedChannel( new ChannelInitializer() { @Override - protected void initChannel(Channel ch) throws Exception { + protected void initChannel(Channel ch) { initializer.accept(ch); } }); diff --git a/proxy/src/test/java/google/registry/proxy/handler/BackendMetricsHandlerTest.java b/proxy/src/test/java/google/registry/proxy/handler/BackendMetricsHandlerTest.java index 02f475bd5..4823ebf80 100644 --- a/proxy/src/test/java/google/registry/proxy/handler/BackendMetricsHandlerTest.java +++ b/proxy/src/test/java/google/registry/proxy/handler/BackendMetricsHandlerTest.java @@ -81,7 +81,7 @@ class BackendMetricsHandlerTest { new EmbeddedChannel( new ChannelInitializer() { @Override - protected void initChannel(EmbeddedChannel ch) throws Exception { + protected void initChannel(EmbeddedChannel ch) { ch.attr(PROTOCOL_KEY).set(backendProtocol); ch.attr(RELAY_CHANNEL_KEY).set(frontendChannel); ch.pipeline().addLast(handler); diff --git a/proxy/src/test/java/google/registry/proxy/handler/EppServiceHandlerTest.java b/proxy/src/test/java/google/registry/proxy/handler/EppServiceHandlerTest.java index 9f9122f69..134e8932a 100644 --- a/proxy/src/test/java/google/registry/proxy/handler/EppServiceHandlerTest.java +++ b/proxy/src/test/java/google/registry/proxy/handler/EppServiceHandlerTest.java @@ -82,8 +82,8 @@ class EppServiceHandlerTest { private EmbeddedChannel channel; - private void setHandshakeSuccess(EmbeddedChannel channel, X509Certificate certificate) - throws Exception { + private void setHandshakeSuccess(EmbeddedChannel channel, X509Certificate certificate) { + @SuppressWarnings("unused") Promise unusedPromise = channel.attr(CLIENT_CERTIFICATE_PROMISE_KEY).get().setSuccess(certificate); } @@ -92,7 +92,7 @@ class EppServiceHandlerTest { setHandshakeSuccess(channel, clientCertificate); } - private void setHandshakeFailure(EmbeddedChannel channel) throws Exception { + private void setHandshakeFailure(EmbeddedChannel channel) { Promise unusedPromise = channel .attr(CLIENT_CERTIFICATE_PROMISE_KEY) @@ -135,12 +135,12 @@ class EppServiceHandlerTest { channel = setUpNewChannel(eppServiceHandler); } - private EmbeddedChannel setUpNewChannel(EppServiceHandler handler) throws Exception { + private EmbeddedChannel setUpNewChannel(EppServiceHandler handler) { return new EmbeddedChannel( DefaultChannelId.newInstance(), new ChannelInitializer() { @Override - protected void initChannel(EmbeddedChannel ch) throws Exception { + protected void initChannel(EmbeddedChannel ch) { ch.attr(REMOTE_ADDRESS_KEY).set(CLIENT_ADDRESS); ch.attr(CLIENT_CERTIFICATE_PROMISE_KEY).set(ch.eventLoop().newPromise()); ch.pipeline().addLast(handler); diff --git a/proxy/src/test/java/google/registry/proxy/handler/FrontendMetricsHandlerTest.java b/proxy/src/test/java/google/registry/proxy/handler/FrontendMetricsHandlerTest.java index b8d03925e..85d26988b 100644 --- a/proxy/src/test/java/google/registry/proxy/handler/FrontendMetricsHandlerTest.java +++ b/proxy/src/test/java/google/registry/proxy/handler/FrontendMetricsHandlerTest.java @@ -61,7 +61,7 @@ class FrontendMetricsHandlerTest { new EmbeddedChannel( new ChannelInitializer() { @Override - protected void initChannel(EmbeddedChannel ch) throws Exception { + protected void initChannel(EmbeddedChannel ch) { ch.attr(PROTOCOL_KEY).set(frontendProtocol); ch.attr(CLIENT_CERTIFICATE_HASH_KEY).set(CLIENT_CERT_HASH); ch.pipeline().addLast(handler); diff --git a/proxy/src/test/java/google/registry/proxy/quota/QuotaManagerTest.java b/proxy/src/test/java/google/registry/proxy/quota/QuotaManagerTest.java index b42f2cd46..450cd73e3 100644 --- a/proxy/src/test/java/google/registry/proxy/quota/QuotaManagerTest.java +++ b/proxy/src/test/java/google/registry/proxy/quota/QuotaManagerTest.java @@ -67,7 +67,7 @@ class QuotaManagerTest { } @Test - void testSuccess_rebate() throws Exception { + void testSuccess_rebate() { DateTime grantedTokenRefillTime = clock.nowUtc(); response = QuotaResponse.create(true, USER_ID, grantedTokenRefillTime); QuotaRebate rebate = QuotaRebate.create(response);