1
0
mirror of https://github.com/google/nomulus synced 2026-01-06 21:47:31 +00:00

Wrap tm().loadByKey() in a transaction when caching is not enabled. (#2030)

We have caching enabled so we never exercised this line.
This commit is contained in:
Lai Jiang
2023-05-19 14:21:48 -04:00
committed by GitHub
parent 6883093735
commit 6cbc2fa5ef

View File

@@ -403,7 +403,7 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B
public static ImmutableMap<VKey<? extends EppResource>, EppResource> loadCached(
Iterable<VKey<? extends EppResource>> keys) {
if (!RegistryConfig.isEppResourceCachingEnabled()) {
return tm().loadByKeys(keys);
return tm().transact(() -> tm().loadByKeys(keys));
}
return ImmutableMap.copyOf(cacheEppResources.getAll(keys));
}
@@ -416,7 +416,7 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B
*/
public static <T extends EppResource> T loadCached(VKey<T> key) {
if (!RegistryConfig.isEppResourceCachingEnabled()) {
return tm().loadByKey(key);
return tm().transact(() -> tm().loadByKey(key));
}
// Safe to cast because loading a Key<T> returns an entity of type T.
@SuppressWarnings("unchecked")