Skip to content

Commit 35d9aee

Browse files
committed
Marked exceptions for create and deletes as non-idempotent.
1 parent b29df66 commit 35d9aee

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

gcloud-java-dns/src/main/java/com/google/gcloud/dns/DnsException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public class DnsException extends BaseServiceException {
3939
new Error(null, "rateLimitExceeded"));
4040
private static final long serialVersionUID = 490302380416260252L;
4141

42-
public DnsException(IOException exception) {
43-
super(exception, true);
42+
public DnsException(IOException exception, boolean idempotent) {
43+
super(exception, idempotent);
4444
}
4545

4646
private DnsException(int code, String message) {

gcloud-java-dns/src/main/java/com/google/gcloud/dns/spi/DefaultDnsRpc.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class DefaultDnsRpc implements DnsRpc {
3636
private final Dns dns;
3737
private final DnsOptions options;
3838

39-
private static DnsException translate(IOException exception) {
40-
return new DnsException(exception);
39+
private static DnsException translate(IOException exception, boolean idempotent) {
40+
return new DnsException(exception, idempotent);
4141
}
4242

4343
/**
@@ -61,7 +61,7 @@ public ManagedZone create(ManagedZone zone, Map<Option, ?> options) throws DnsEx
6161
.setFields(FIELDS.getString(options))
6262
.execute();
6363
} catch (IOException ex) {
64-
throw translate(ex);
64+
throw translate(ex, false);
6565
}
6666
}
6767

@@ -73,7 +73,7 @@ public ManagedZone getZone(String zoneName, Map<Option, ?> options) throws DnsEx
7373
.setFields(FIELDS.getString(options))
7474
.execute();
7575
} catch (IOException ex) {
76-
DnsException serviceException = translate(ex);
76+
DnsException serviceException = translate(ex, true);
7777
if (serviceException.code() == HTTP_NOT_FOUND) {
7878
return null;
7979
}
@@ -93,7 +93,7 @@ public ListResult<ManagedZone> listZones(Map<Option, ?> options) throws DnsExcep
9393
.execute();
9494
return of(zoneList.getNextPageToken(), zoneList.getManagedZones());
9595
} catch (IOException ex) {
96-
throw translate(ex);
96+
throw translate(ex, true);
9797
}
9898
}
9999

@@ -103,7 +103,7 @@ public boolean deleteZone(String zoneName) throws DnsException {
103103
dns.managedZones().delete(this.options.projectId(), zoneName).execute();
104104
return true;
105105
} catch (IOException ex) {
106-
DnsException serviceException = translate(ex);
106+
DnsException serviceException = translate(ex, false);
107107
if (serviceException.code() == HTTP_NOT_FOUND) {
108108
return false;
109109
}
@@ -126,7 +126,7 @@ public ListResult<ResourceRecordSet> listRecordSets(String zoneName, Map<Option,
126126
.execute();
127127
return of(response.getNextPageToken(), response.getRrsets());
128128
} catch (IOException ex) {
129-
throw translate(ex);
129+
throw translate(ex, true);
130130
}
131131
}
132132

@@ -136,7 +136,7 @@ public Project getProject(Map<Option, ?> options) throws DnsException {
136136
return dns.projects().get(this.options.projectId())
137137
.setFields(FIELDS.getString(options)).execute();
138138
} catch (IOException ex) {
139-
throw translate(ex);
139+
throw translate(ex, true);
140140
}
141141
}
142142

@@ -148,7 +148,7 @@ public Change applyChangeRequest(String zoneName, Change changeRequest, Map<Opti
148148
.setFields(FIELDS.getString(options))
149149
.execute();
150150
} catch (IOException ex) {
151-
throw translate(ex);
151+
throw translate(ex, false);
152152
}
153153
}
154154

@@ -160,7 +160,7 @@ public Change getChangeRequest(String zoneName, String changeRequestId, Map<Opti
160160
.setFields(FIELDS.getString(options))
161161
.execute();
162162
} catch (IOException ex) {
163-
DnsException serviceException = translate(ex);
163+
DnsException serviceException = translate(ex, true);
164164
if (serviceException.code() == HTTP_NOT_FOUND) {
165165
if ("entity.parameters.changeId".equals(serviceException.location())
166166
|| (serviceException.getMessage() != null
@@ -190,7 +190,7 @@ public ListResult<Change> listChangeRequests(String zoneName, Map<Option, ?> opt
190190
ChangesListResponse response = request.execute();
191191
return of(response.getNextPageToken(), response.getChanges());
192192
} catch (IOException ex) {
193-
throw translate(ex);
193+
throw translate(ex, true);
194194
}
195195
}
196196
}

0 commit comments

Comments
 (0)