Skip to content

Commit 16d2672

Browse files
authored
s2a: Don't allow S2AStub to be set
S2AStub is an internal API and shouldn't be used outside of s2a. It is still available for tests. IntegrationTest was moved to io.grpc.s2a. It uses a io.grpc.s2a class, so shouldn't be in internal.handler
1 parent 9e54e8e commit 16d2672

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static com.google.common.base.Preconditions.checkNotNull;
2121
import static com.google.common.base.Strings.isNullOrEmpty;
2222

23+
import com.google.common.annotations.VisibleForTesting;
2324
import com.google.errorprone.annotations.CanIgnoreReturnValue;
2425
import io.grpc.Channel;
2526
import io.grpc.ChannelCredentials;
@@ -110,7 +111,8 @@ public Builder setLocalUid(String localUid) {
110111
* Sets the stub to use to communicate with S2A. This is only used for testing that the
111112
* stream to S2A gets closed.
112113
*/
113-
public Builder setStub(S2AStub stub) {
114+
@VisibleForTesting
115+
Builder setStub(S2AStub stub) {
114116
checkNotNull(stub);
115117
this.stub = stub;
116118
return this;
@@ -130,4 +132,4 @@ InternalProtocolNegotiator.ClientFactory buildProtocolNegotiatorFactory() {
130132
}
131133

132134
private S2AChannelCredentials() {}
133-
}
135+
}

s2a/src/main/java/io/grpc/s2a/internal/handshaker/S2AStub.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public class S2AStub implements AutoCloseable {
4444
private boolean doneWriting = false;
4545
private boolean isClosed = false;
4646

47-
static S2AStub newInstance(S2AServiceGrpc.S2AServiceStub serviceStub) {
47+
@VisibleForTesting
48+
public static S2AStub newInstance(S2AServiceGrpc.S2AServiceStub serviceStub) {
4849
checkNotNull(serviceStub);
4950
return new S2AStub(serviceStub);
5051
}
@@ -224,4 +225,4 @@ SessionResp getResultOrThrow() throws IOException {
224225
return response.get();
225226
}
226227
}
227-
}
228+
}

s2a/src/test/java/io/grpc/s2a/internal/handshaker/IntegrationTest.java s2a/src/test/java/io/grpc/s2a/IntegrationTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package io.grpc.s2a.internal.handshaker;
17+
package io.grpc.s2a;
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -37,6 +37,8 @@
3737
import io.grpc.s2a.S2AChannelCredentials;
3838
import io.grpc.s2a.internal.channel.S2AHandshakerServiceChannel;
3939
import io.grpc.s2a.internal.handshaker.FakeS2AServer;
40+
import io.grpc.s2a.internal.handshaker.S2AServiceGrpc;
41+
import io.grpc.s2a.internal.handshaker.S2AStub;
4042
import io.grpc.stub.StreamObserver;
4143
import io.grpc.testing.protobuf.SimpleRequest;
4244
import io.grpc.testing.protobuf.SimpleResponse;

0 commit comments

Comments
 (0)