mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Add Runnable overrides to ease use of Java 8 language features
Runnable and Callable are both @FunctionalInterfaces. The difference is that Callable requires a return value whereas Runnable does not, so in situations where we don't care about a return value, rather than having to add an unnecessary 'return null;' at the end of the lambda, we can simply use a non-returning Runnable instead. Unfortunately, owing to legacy reasons, Runnable is not declared to throw checked exceptions whereas Callable is, so in situations where checked exceptions are thrown we still need to have a 'return null;' call at the end. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=172935400
This commit is contained in:
parent
d577a281b8
commit
1790914058
13 changed files with 141 additions and 134 deletions
|
@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.googlecode.objectify.VoidWork;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.groups.GroupsConnection;
|
||||
import google.registry.groups.GroupsConnection.Role;
|
||||
|
@ -134,12 +133,7 @@ public final class SyncGroupMembersAction implements Runnable {
|
|||
new ImmutableMap.Builder<>();
|
||||
for (final Registrar registrar : dirtyRegistrars) {
|
||||
try {
|
||||
retrier.callWithRetry(
|
||||
() -> {
|
||||
syncRegistrarContacts(registrar);
|
||||
return null;
|
||||
},
|
||||
RuntimeException.class);
|
||||
retrier.callWithRetry(() -> syncRegistrarContacts(registrar), RuntimeException.class);
|
||||
resultsBuilder.put(registrar, Optional.<Throwable>empty());
|
||||
} catch (Throwable e) {
|
||||
logger.severe(e, e.getMessage());
|
||||
|
@ -171,11 +165,7 @@ public final class SyncGroupMembersAction implements Runnable {
|
|||
registrarsToSave.add(result.getKey().asBuilder().setContactsRequireSyncing(false).build());
|
||||
}
|
||||
}
|
||||
ofy().transactNew(new VoidWork() {
|
||||
@Override
|
||||
public void vrun() {
|
||||
ofy().save().entities(registrarsToSave.build());
|
||||
}});
|
||||
ofy().transactNew(() -> ofy().save().entities(registrarsToSave.build()));
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue