Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s2a: Don't allow S2AStub to be set #11722

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
ejona86 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading