mirror of
https://github.com/google/nomulus
synced 2026-09-04 15:17:13 +00:00
Remove caps/pins on some dependencies (#2348)
Also re-organized the dependencies.gradle file. Not all caps/pins are removed at this point, but I think this is enough change for one PR.
This commit is contained in:
@@ -33,7 +33,7 @@ import google.registry.persistence.VKey;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.commons.lang3.stream.Streams;
|
||||
import java.util.Set;
|
||||
|
||||
/** Helpers for {@link BsaLabel}. */
|
||||
public final class BsaLabelUtils {
|
||||
@@ -41,7 +41,7 @@ public final class BsaLabelUtils {
|
||||
private BsaLabelUtils() {}
|
||||
|
||||
static final CacheLoader<VKey<BsaLabel>, Optional<BsaLabel>> CACHE_LOADER =
|
||||
new CacheLoader<VKey<BsaLabel>, Optional<BsaLabel>>() {
|
||||
new CacheLoader<>() {
|
||||
|
||||
@Override
|
||||
public Optional<BsaLabel> load(VKey<BsaLabel> key) {
|
||||
@@ -49,11 +49,11 @@ public final class BsaLabelUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<VKey<BsaLabel>, Optional<BsaLabel>> loadAll(
|
||||
Iterable<? extends VKey<BsaLabel>> keys) {
|
||||
public Map<? extends VKey<BsaLabel>, ? extends Optional<BsaLabel>> loadAll(
|
||||
Set<? extends VKey<BsaLabel>> keys) {
|
||||
ImmutableMap<VKey<? extends BsaLabel>, BsaLabel> existingLabels =
|
||||
replicaTm().reTransact(() -> replicaTm().loadByKeysIfPresent(keys));
|
||||
return Streams.of(keys)
|
||||
return keys.stream()
|
||||
.collect(
|
||||
toImmutableMap(key -> key, key -> Optional.ofNullable(existingLabels.get(key))));
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public final class BsaLabelUtils {
|
||||
* <p>Since the cached BSA labels have the same usage pattern as the cached EppResources, the
|
||||
* cache configuration for the latter are reused here.
|
||||
*/
|
||||
private static LoadingCache<VKey<BsaLabel>, Optional<BsaLabel>> cacheBsaLabels =
|
||||
private static final LoadingCache<VKey<BsaLabel>, Optional<BsaLabel>> cacheBsaLabels =
|
||||
createBsaLabelsCache(getEppResourceCachingDuration());
|
||||
|
||||
private static LoadingCache<VKey<BsaLabel>, Optional<BsaLabel>> createBsaLabelsCache(
|
||||
|
||||
@@ -354,7 +354,7 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B
|
||||
}
|
||||
|
||||
static final CacheLoader<VKey<? extends EppResource>, EppResource> CACHE_LOADER =
|
||||
new CacheLoader<VKey<? extends EppResource>, EppResource>() {
|
||||
new CacheLoader<>() {
|
||||
|
||||
@Override
|
||||
public EppResource load(VKey<? extends EppResource> key) {
|
||||
@@ -362,8 +362,8 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<VKey<? extends EppResource>, EppResource> loadAll(
|
||||
Iterable<? extends VKey<? extends EppResource>> keys) {
|
||||
public Map<? extends VKey<? extends EppResource>, ? extends EppResource> loadAll(
|
||||
Set<? extends VKey<? extends EppResource>> keys) {
|
||||
return replicaTm().reTransact(() -> replicaTm().loadByKeys(keys));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Streams;
|
||||
import google.registry.config.RegistryConfig;
|
||||
import google.registry.model.contact.Contact;
|
||||
import google.registry.model.domain.Domain;
|
||||
@@ -42,6 +41,7 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
@@ -83,7 +83,7 @@ public final class ForeignKeyUtils {
|
||||
* active at or after the specified moment in time.
|
||||
*
|
||||
* <p>The returned map will omit any foreign keys for which the {@link EppResource} doesn't exist
|
||||
* or has been soft deleted.
|
||||
* or has been soft-deleted.
|
||||
*/
|
||||
public static <E extends EppResource> ImmutableMap<String, VKey<E>> load(
|
||||
Class<E> clazz, Collection<String> foreignKeys, final DateTime now) {
|
||||
@@ -94,7 +94,7 @@ public final class ForeignKeyUtils {
|
||||
|
||||
/**
|
||||
* Helper method to load {@link VKey}s to all the most recent {@link EppResource}s for the given
|
||||
* foreign keys, regardless of whether or not they have been soft-deleted.
|
||||
* foreign keys, regardless of whether they have been soft-deleted.
|
||||
*
|
||||
* <p>Used by both the cached (w/o deletion check) and the non-cached (with deletion check) calls.
|
||||
*
|
||||
@@ -129,24 +129,25 @@ public final class ForeignKeyUtils {
|
||||
|
||||
private static final CacheLoader<VKey<? extends EppResource>, Optional<MostRecentResource>>
|
||||
CACHE_LOADER =
|
||||
new CacheLoader<VKey<? extends EppResource>, Optional<MostRecentResource>>() {
|
||||
new CacheLoader<>() {
|
||||
|
||||
@Override
|
||||
public Optional<MostRecentResource> load(VKey<? extends EppResource> key) {
|
||||
return loadAll(ImmutableList.of(key)).get(key);
|
||||
return loadAll(ImmutableSet.of(key)).get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<VKey<? extends EppResource>, Optional<MostRecentResource>> loadAll(
|
||||
Iterable<? extends VKey<? extends EppResource>> keys) {
|
||||
if (!keys.iterator().hasNext()) {
|
||||
public Map<
|
||||
? extends VKey<? extends EppResource>, ? extends Optional<MostRecentResource>>
|
||||
loadAll(Set<? extends VKey<? extends EppResource>> keys) {
|
||||
if (keys.isEmpty()) {
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
// It is safe to use the resource type of first element because when this function is
|
||||
// called, it is always passed with a list of VKeys with the same type.
|
||||
Class<? extends EppResource> clazz = keys.iterator().next().getKind();
|
||||
ImmutableList<String> foreignKeys =
|
||||
Streams.stream(keys).map(key -> (String) key.getKey()).collect(toImmutableList());
|
||||
keys.stream().map(key -> (String) key.getKey()).collect(toImmutableList());
|
||||
ImmutableMap<String, MostRecentResource> existingKeys =
|
||||
ForeignKeyUtils.load(clazz, foreignKeys, true);
|
||||
// The above map only contains keys that exist in the database, so we re-add the
|
||||
@@ -166,7 +167,7 @@ public final class ForeignKeyUtils {
|
||||
*
|
||||
* <p>Note that here the key of the {@link LoadingCache} is of type {@code VKey<? extends
|
||||
* EppResource>}, but they are not legal {@link VKey}s to {@link EppResource}s, whose keys are the
|
||||
* SQL primary keys, i.e. the {@code repoId}s. Instead, their keys are the foreign keys used to
|
||||
* SQL primary keys, i.e., the {@code repoId}s. Instead, their keys are the foreign keys used to
|
||||
* query the database. We use {@link VKey} here because it is a convenient composite class that
|
||||
* contains both the resource type and the foreign key, which are needed to for the query and
|
||||
* caching.
|
||||
@@ -199,7 +200,7 @@ public final class ForeignKeyUtils {
|
||||
* that are active at or after the specified moment in time, using the cache if enabled.
|
||||
*
|
||||
* <p>The returned map will omit any keys for which the {@link EppResource} doesn't exist or has
|
||||
* been soft deleted.
|
||||
* been soft-deleted.
|
||||
*
|
||||
* <p>Don't use the cached version of this method unless you really need it for performance
|
||||
* reasons, and are OK with the trade-offs in loss of transactional consistency.
|
||||
|
||||
@@ -322,19 +322,18 @@ public class AllocationToken extends UpdateAutoTimestampEntity implements Builda
|
||||
ALLOCATION_TOKENS_CACHE =
|
||||
CacheUtils.newCacheBuilder(getSingletonCacheRefreshDuration())
|
||||
.build(
|
||||
new CacheLoader<VKey<AllocationToken>, Optional<AllocationToken>>() {
|
||||
new CacheLoader<>() {
|
||||
@Override
|
||||
public Optional<AllocationToken> load(VKey<AllocationToken> key) {
|
||||
return tm().reTransact(() -> tm().loadByKeyIfPresent(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<VKey<AllocationToken>, Optional<AllocationToken>> loadAll(
|
||||
Iterable<? extends VKey<AllocationToken>> keys) {
|
||||
ImmutableSet<VKey<AllocationToken>> keySet = ImmutableSet.copyOf(keys);
|
||||
public Map<? extends VKey<AllocationToken>, ? extends Optional<AllocationToken>>
|
||||
loadAll(Set<? extends VKey<AllocationToken>> keys) {
|
||||
return tm().reTransact(
|
||||
() ->
|
||||
keySet.stream()
|
||||
keys.stream()
|
||||
.collect(
|
||||
toImmutableMap(
|
||||
key -> key, key -> tm().loadByKeyIfPresent(key))));
|
||||
|
||||
@@ -16,8 +16,8 @@ package google.registry.model.tld;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Maps.toMap;
|
||||
import static google.registry.config.RegistryConfig.getSingletonCacheRefreshDuration;
|
||||
import static google.registry.model.EntityYamlUtils.createObjectMapper;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
@@ -106,7 +106,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
@Column(name = "tld_name", nullable = false)
|
||||
String tldStr;
|
||||
|
||||
/** The suffix that identifies roids as belonging to this specific tld, e.g. -HOW for .how. */
|
||||
/** The suffix that identifies roids as belonging to this specific tld, e.g., -HOW for .how. */
|
||||
String roidSuffix;
|
||||
|
||||
/** Default values for all the relevant TLD parameters. */
|
||||
@@ -234,7 +234,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
private static final LoadingCache<String, Tld> CACHE =
|
||||
CacheUtils.newCacheBuilder(getSingletonCacheRefreshDuration())
|
||||
.build(
|
||||
new CacheLoader<String, Tld>() {
|
||||
new CacheLoader<>() {
|
||||
@Override
|
||||
public Tld load(final String tld) {
|
||||
return tm().reTransact(() -> tm().loadByKeyIfPresent(createVKey(tld)))
|
||||
@@ -242,9 +242,9 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Tld> loadAll(Iterable<? extends String> tlds) {
|
||||
public Map<? extends String, ? extends Tld> loadAll(Set<? extends String> tlds) {
|
||||
ImmutableMap<String, VKey<Tld>> keysMap =
|
||||
toMap(ImmutableSet.copyOf(tlds), Tld::createVKey);
|
||||
tlds.stream().collect(toImmutableMap(tld -> tld, Tld::createVKey));
|
||||
Map<VKey<? extends Tld>, Tld> entities =
|
||||
tm().reTransact(() -> tm().loadByKeysIfPresent(keysMap.values()));
|
||||
return Maps.transformEntries(keysMap, (k, v) -> entities.getOrDefault(v, null));
|
||||
|
||||
@@ -92,11 +92,11 @@ class IcannReportingStagerTest {
|
||||
String expectedReport2 = "fooField,barField\r\n56,78";
|
||||
byte[] generatedFile1 =
|
||||
gcsUtils.readBytesFrom(
|
||||
BlobId.of("test-bucket/icann/monthly/2017-06", "fooTld-activity-201706.csv"));
|
||||
BlobId.of("test-bucket", "icann/monthly/2017-06/fooTld-activity-201706.csv"));
|
||||
assertThat(new String(generatedFile1, UTF_8)).isEqualTo(expectedReport1);
|
||||
byte[] generatedFile2 =
|
||||
gcsUtils.readBytesFrom(
|
||||
BlobId.of("test-bucket/icann/monthly/2017-06", "barTld-activity-201706.csv"));
|
||||
BlobId.of("test-bucket", "icann/monthly/2017-06/barTld-activity-201706.csv"));
|
||||
assertThat(new String(generatedFile2, UTF_8)).isEqualTo(expectedReport2);
|
||||
}
|
||||
|
||||
@@ -134,11 +134,11 @@ class IcannReportingStagerTest {
|
||||
String expectedReport2 = "registrar,iana,field\r\n\"reg1\",123,30\r\nTotals,,30";
|
||||
byte[] generatedFile1 =
|
||||
gcsUtils.readBytesFrom(
|
||||
BlobId.of("test-bucket/icann/monthly/2017-06", "fooTld-transactions-201706.csv"));
|
||||
BlobId.of("test-bucket", "icann/monthly/2017-06/fooTld-transactions-201706.csv"));
|
||||
assertThat(new String(generatedFile1, UTF_8)).isEqualTo(expectedReport1);
|
||||
byte[] generatedFile2 =
|
||||
gcsUtils.readBytesFrom(
|
||||
BlobId.of("test-bucket/icann/monthly/2017-06", "barTld-transactions-201706.csv"));
|
||||
BlobId.of("test-bucket", "icann/monthly/2017-06/barTld-transactions-201706.csv"));
|
||||
assertThat(new String(generatedFile2, UTF_8)).isEqualTo(expectedReport2);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class IcannReportingStagerTest {
|
||||
|
||||
String expectedManifest = "fooTld-transactions-201706.csv\nbarTld-activity-201706.csv\n";
|
||||
byte[] generatedManifest =
|
||||
gcsUtils.readBytesFrom(BlobId.of("test-bucket/icann/monthly/2017-06", "MANIFEST.txt"));
|
||||
gcsUtils.readBytesFrom(BlobId.of("test-bucket", "icann/monthly/2017-06/MANIFEST.txt"));
|
||||
assertThat(new String(generatedManifest, UTF_8)).isEqualTo(expectedManifest);
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -90,13 +90,13 @@ class IcannReportingUploadActionTest {
|
||||
void beforeEach() throws Exception {
|
||||
createTlds("tld", "foo");
|
||||
gcsUtils.createFromBytes(
|
||||
BlobId.of("basin/icann/monthly/2006-06", "tld-transactions-200606.csv"), PAYLOAD_SUCCESS);
|
||||
BlobId.of("basin", "icann/monthly/2006-06/tld-transactions-200606.csv"), PAYLOAD_SUCCESS);
|
||||
gcsUtils.createFromBytes(
|
||||
BlobId.of("basin/icann/monthly/2006-06", "tld-activity-200606.csv"), PAYLOAD_FAIL);
|
||||
BlobId.of("basin", "icann/monthly/2006-06/tld-activity-200606.csv"), PAYLOAD_FAIL);
|
||||
gcsUtils.createFromBytes(
|
||||
BlobId.of("basin/icann/monthly/2006-06", "foo-transactions-200606.csv"), PAYLOAD_SUCCESS);
|
||||
BlobId.of("basin", "icann/monthly/2006-06/foo-transactions-200606.csv"), PAYLOAD_SUCCESS);
|
||||
gcsUtils.createFromBytes(
|
||||
BlobId.of("basin/icann/monthly/2006-06", "foo-activity-200606.csv"), PAYLOAD_SUCCESS);
|
||||
BlobId.of("basin", "icann/monthly/2006-06/foo-activity-200606.csv"), PAYLOAD_SUCCESS);
|
||||
when(mockReporter.send(PAYLOAD_SUCCESS, "tld-transactions-200606.csv")).thenReturn(true);
|
||||
when(mockReporter.send(PAYLOAD_SUCCESS, "foo-transactions-200606.csv")).thenReturn(true);
|
||||
when(mockReporter.send(PAYLOAD_FAIL, "tld-activity-200606.csv")).thenReturn(false);
|
||||
@@ -150,9 +150,9 @@ class IcannReportingUploadActionTest {
|
||||
Cursor.createScoped(
|
||||
CursorType.ICANN_UPLOAD_TX, DateTime.parse("2006-01-01TZ"), Tld.get("tld")));
|
||||
gcsUtils.createFromBytes(
|
||||
BlobId.of("basin/icann/monthly/2005-12", "tld-transactions-200512.csv"), PAYLOAD_SUCCESS);
|
||||
BlobId.of("basin", "icann/monthly/2005-12/tld-transactions-200512.csv"), PAYLOAD_SUCCESS);
|
||||
gcsUtils.createFromBytes(
|
||||
BlobId.of("basin/icann/monthly/2005-12", "tld-activity-200512.csv"), PAYLOAD_SUCCESS);
|
||||
BlobId.of("basin", "icann/monthly/2005-12/tld-activity-200512.csv"), PAYLOAD_SUCCESS);
|
||||
when(mockReporter.send(PAYLOAD_SUCCESS, "tld-activity-200512.csv")).thenReturn(true);
|
||||
when(mockReporter.send(PAYLOAD_SUCCESS, "tld-transactions-200512.csv")).thenReturn(true);
|
||||
|
||||
@@ -176,7 +176,7 @@ class IcannReportingUploadActionTest {
|
||||
@Test
|
||||
void testSuccess_advancesCursor() throws Exception {
|
||||
gcsUtils.createFromBytes(
|
||||
BlobId.of("basin/icann/monthly/2006-06", "tld-activity-200606.csv"), PAYLOAD_SUCCESS);
|
||||
BlobId.of("basin", "icann/monthly/2006-06/tld-activity-200606.csv"), PAYLOAD_SUCCESS);
|
||||
when(mockReporter.send(PAYLOAD_SUCCESS, "tld-activity-200606.csv")).thenReturn(true);
|
||||
IcannReportingUploadAction action = createAction();
|
||||
action.run();
|
||||
|
||||
Reference in New Issue
Block a user