Add transactional import helper in RdeImportUtilsTest

This is needed to fix an inability in Java 8 to correctly infer the type
when the transaction was being allowed to return the value it loaded. The
error was:

INFO: Compilation unit  has error diagnostics: [third_party/java_src/gtld/javatests/google/registry/rde/imports/RdeImportUtilsTest.java:109: error: incompatible types: inference variable R has incompatible bounds
    ofy().transact(() -> rdeImportUtils.importEppResource(newContact));
                  ^
    upper bounds: java.lang.Object
    lower bounds: void, third_party/java_src/gtld/javatests/google/registry/rde/imports/RdeImportUtilsTest.java:132:
error: incompatible types: inference variable R has incompatible bounds

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179082154
This commit is contained in:
mcilwain 2017-12-14 12:51:55 -08:00 committed by Ben McIlwain
parent 9157930983
commit c8059d4d8a
2 changed files with 22 additions and 11 deletions

View file

@ -110,8 +110,8 @@ public class RdeImportUtils {
* <p>If the resource is imported, {@link ForeignKeyIndex} and {@link EppResourceIndex} are also
* created.
*/
public <T extends EppResource & ForeignKeyedEppResource> void
importEppResource(final T resource) {
public <T extends EppResource & ForeignKeyedEppResource> void importEppResource(
final T resource) {
Object existing = ofy.load().key(Key.create(resource)).now();
if (existing != null) {
// This will roll back the transaction and prevent duplicate history entries from being saved.