Skip to content

Commit 7f26712

Browse files
committed
Check localIdentity is null before setting it.
1 parent 08f8342 commit 7f26712

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public static final class Builder {
7373
@CanIgnoreReturnValue
7474
public Builder setLocalSpiffeId(String localSpiffeId) {
7575
checkNotNull(localSpiffeId);
76+
checkArgument(localIdentity == null, "localIdentity is already set.");
7677
localIdentity = S2AIdentity.fromSpiffeId(localSpiffeId);
7778
return this;
7879
}
@@ -85,6 +86,7 @@ public Builder setLocalSpiffeId(String localSpiffeId) {
8586
@CanIgnoreReturnValue
8687
public Builder setLocalHostname(String localHostname) {
8788
checkNotNull(localHostname);
89+
checkArgument(localIdentity == null, "localIdentity is already set.");
8890
localIdentity = S2AIdentity.fromHostname(localHostname);
8991
return this;
9092
}
@@ -97,6 +99,7 @@ public Builder setLocalHostname(String localHostname) {
9799
@CanIgnoreReturnValue
98100
public Builder setLocalUid(String localUid) {
99101
checkNotNull(localUid);
102+
checkArgument(localIdentity == null, "localIdentity is already set.");
100103
localIdentity = S2AIdentity.fromUid(localUid);
101104
return this;
102105
}

0 commit comments

Comments
 (0)