Account for GoogleJsonResponseException#getDetails returning null

Apparently, this can happen

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=223163802
This commit is contained in:
guyben 2018-11-28 07:33:45 -08:00 committed by jianglai
parent c2ee453745
commit dbdc69916a
5 changed files with 22 additions and 13 deletions

View file

@ -19,7 +19,7 @@ import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.util.DomainNameUtils.getSecondLevelDomain;
import com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo;
import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.services.dns.Dns;
import com.google.api.services.dns.model.Change;
@ -390,12 +390,12 @@ public class CloudDnsWriter extends BaseDnsWriter {
try {
dnsConnection.changes().create(projectId, zoneName, change).execute();
} catch (GoogleJsonResponseException e) {
List<ErrorInfo> errors = e.getDetails().getErrors();
GoogleJsonError err = e.getDetails();
// We did something really wrong here, just give up and re-throw
if (errors.size() > 1) {
if (err == null || err.getErrors().size() > 1) {
throw new RuntimeException(e);
}
String errorReason = errors.get(0).getReason();
String errorReason = err.getErrors().get(0).getReason();
if (RETRYABLE_EXCEPTION_REASONS.contains(errorReason)) {
throw new ZoneStateException(errorReason);