Skip to content

Commit

Permalink
s2a: Don't allow S2AStub to be set
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ejona86 authored Feb 14, 2025
1 parent 9e54e8e commit 16d2672
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;

import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.grpc.Channel;
import io.grpc.ChannelCredentials;
Expand Down Expand Up @@ -110,7 +111,8 @@ public Builder setLocalUid(String localUid) {
* Sets the stub to use to communicate with S2A. This is only used for testing that the
* stream to S2A gets closed.
*/
public Builder setStub(S2AStub stub) {
@VisibleForTesting
Builder setStub(S2AStub stub) {
checkNotNull(stub);
this.stub = stub;
return this;
Expand All @@ -130,4 +132,4 @@ InternalProtocolNegotiator.ClientFactory buildProtocolNegotiatorFactory() {
}

private S2AChannelCredentials() {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class S2AStub implements AutoCloseable {
private boolean doneWriting = false;
private boolean isClosed = false;

static S2AStub newInstance(S2AServiceGrpc.S2AServiceStub serviceStub) {
@VisibleForTesting
public static S2AStub newInstance(S2AServiceGrpc.S2AServiceStub serviceStub) {
checkNotNull(serviceStub);
return new S2AStub(serviceStub);
}
Expand Down Expand Up @@ -224,4 +225,4 @@ SessionResp getResultOrThrow() throws IOException {
return response.get();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.s2a.internal.handshaker;
package io.grpc.s2a;

import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand All @@ -37,6 +37,8 @@
import io.grpc.s2a.S2AChannelCredentials;
import io.grpc.s2a.internal.channel.S2AHandshakerServiceChannel;
import io.grpc.s2a.internal.handshaker.FakeS2AServer;
import io.grpc.s2a.internal.handshaker.S2AServiceGrpc;
import io.grpc.s2a.internal.handshaker.S2AStub;
import io.grpc.stub.StreamObserver;
import io.grpc.testing.protobuf.SimpleRequest;
import io.grpc.testing.protobuf.SimpleResponse;
Expand Down

0 comments on commit 16d2672

Please sign in to comment.