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 811fcf9f43
commit 1a5eb40fb5

View file

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