mirror of https://github.com/grpc/grpc-java.git
core,netty,okhttp,alts,inprocess: deprecate usePlaintext(boolean)
This commit is contained in:
parent
1b5aadf068
commit
7af2373a03
|
@ -58,7 +58,7 @@ final class HandshakerServiceChannel {
|
|||
NettyChannelBuilder.forTarget(handshakerAddress)
|
||||
.directExecutor()
|
||||
.eventLoopGroup(new NioEventLoopGroup(1, clientThreadFactory))
|
||||
.usePlaintext(true)
|
||||
.usePlaintext()
|
||||
.build();
|
||||
return channel;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class LoadWorkerTest {
|
|||
int port = Utils.pickUnusedPort();
|
||||
worker = new LoadWorker(port, 0);
|
||||
worker.start();
|
||||
channel = NettyChannelBuilder.forAddress("localhost", port).usePlaintext(true).build();
|
||||
channel = NettyChannelBuilder.forAddress("localhost", port).usePlaintext().build();
|
||||
workerServiceStub = WorkerServiceGrpc.newStub(channel);
|
||||
marksQueue = new LinkedBlockingQueue<Stats.ClientStats>();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit;
|
|||
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/3363")
|
||||
public abstract class ForwardingChannelBuilder<T extends ForwardingChannelBuilder<T>>
|
||||
extends ManagedChannelBuilder<T> {
|
||||
|
||||
/**
|
||||
* The default constructor.
|
||||
*/
|
||||
|
@ -91,9 +92,19 @@ public abstract class ForwardingChannelBuilder<T extends ForwardingChannelBuilde
|
|||
return thisT();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #usePlaintext()} instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public T usePlaintext(boolean skipNegotiation) {
|
||||
delegate().usePlaintext(skipNegotiation);
|
||||
ManagedChannelBuilder<?> o = delegate().usePlaintext(skipNegotiation);
|
||||
return thisT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T usePlaintext() {
|
||||
delegate().usePlaintext();
|
||||
return thisT();
|
||||
}
|
||||
|
||||
|
|
|
@ -152,13 +152,38 @@ public abstract class ManagedChannelBuilder<T extends ManagedChannelBuilder<T>>
|
|||
*
|
||||
* @param skipNegotiation @{code true} if there is a priori knowledge that the endpoint supports
|
||||
* plaintext, {@code false} if plaintext use must be negotiated.
|
||||
* @deprecated Use {@link #usePlaintext()} instead.
|
||||
*
|
||||
* @throws UnsupportedOperationException if plaintext mode is not supported.
|
||||
* @return this
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1772")
|
||||
public abstract T usePlaintext(boolean skipNegotiation);
|
||||
@Deprecated
|
||||
public T usePlaintext(boolean skipNegotiation) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use of a plaintext connection to the server. By default a secure connection mechanism
|
||||
* such as TLS will be used.
|
||||
*
|
||||
* <p>Should only be used for testing or for APIs where the use of such API or the data
|
||||
* exchanged is not sensitive.
|
||||
*
|
||||
* <p>This assumes prior knowledge that the target of this channel is using plaintext. It will
|
||||
* not perform HTTP/1.1 upgrades.
|
||||
*
|
||||
*
|
||||
* @throws UnsupportedOperationException if plaintext mode is not supported.
|
||||
* @return this
|
||||
* @since 1.11.0
|
||||
*/
|
||||
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1772")
|
||||
@SuppressWarnings("deprecation")
|
||||
public T usePlaintext() {
|
||||
return usePlaintext(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the client use TLS.
|
||||
|
|
|
@ -94,12 +94,23 @@ public final class InProcessChannelBuilder extends
|
|||
|
||||
/**
|
||||
* Does nothing.
|
||||
*
|
||||
* @deprecated use {@link #usePlaintext()} instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public InProcessChannelBuilder usePlaintext(boolean skipNegotiation) {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does nothing.
|
||||
*/
|
||||
@Override
|
||||
public InProcessChannelBuilder usePlaintext() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Does nothing. */
|
||||
@Override
|
||||
public InProcessChannelBuilder keepAliveTime(long keepAliveTime, TimeUnit timeUnit) {
|
||||
|
|
|
@ -422,10 +422,5 @@ public class AbstractManagedChannelImplBuilderTest {
|
|||
protected ClientTransportFactory buildTransportFactory() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder usePlaintext(boolean value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public class ManagedChannelImplIdlenessTest {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override public Builder usePlaintext(boolean b) {
|
||||
@Override public Builder usePlaintext() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ public class ManagedChannelImplTest {
|
|||
return NAME_RESOLVER_PARAMS;
|
||||
}
|
||||
|
||||
@Override public Builder usePlaintext(boolean b) {
|
||||
@Override public Builder usePlaintext() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ public class TestServiceClient {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
okBuilder.usePlaintext(true);
|
||||
okBuilder.usePlaintext();
|
||||
}
|
||||
if (fullStreamDecompression) {
|
||||
okBuilder.enableFullStreamDecompression();
|
||||
|
|
|
@ -193,7 +193,7 @@ public class CompressionTest {
|
|||
.decompressorRegistry(clientDecompressors)
|
||||
.compressorRegistry(clientCompressors)
|
||||
.intercept(new ClientCompressorInterceptor())
|
||||
.usePlaintext(true)
|
||||
.usePlaintext()
|
||||
.build();
|
||||
stub = TestServiceGrpc.newBlockingStub(channel);
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ public class StressTestClientTest {
|
|||
|
||||
// Connect to the metrics service
|
||||
ManagedChannel ch = ManagedChannelBuilder.forAddress("localhost", client.getMetricServerPort())
|
||||
.usePlaintext(true)
|
||||
.usePlaintext()
|
||||
.build();
|
||||
|
||||
MetricsServiceGrpc.MetricsServiceBlockingStub stub = MetricsServiceGrpc.newBlockingStub(ch);
|
||||
|
|
|
@ -167,7 +167,7 @@ public class TransportCompressionTest extends AbstractInteropTest {
|
|||
};
|
||||
}
|
||||
})
|
||||
.usePlaintext(true);
|
||||
.usePlaintext();
|
||||
io.grpc.internal.TestingAccessor.setStatsImplementation(
|
||||
builder, createClientCensusStatsModule());
|
||||
return builder.build();
|
||||
|
|
|
@ -78,7 +78,7 @@ public final class ShadingTest {
|
|||
.build().start();
|
||||
channel = ManagedChannelBuilder
|
||||
.forAddress("localhost", server.getPort())
|
||||
.usePlaintext(true)
|
||||
.usePlaintext()
|
||||
.build();
|
||||
SimpleServiceBlockingStub stub = SimpleServiceGrpc.newBlockingStub(channel);
|
||||
assertThat(SimpleResponse.getDefaultInstance())
|
||||
|
|
|
@ -226,8 +226,11 @@ public final class NettyChannelBuilder
|
|||
/**
|
||||
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code PLAINTEXT} or
|
||||
* {@code PLAINTEXT_UPGRADE}.
|
||||
*
|
||||
* @deprecated use {@link #usePlaintext()} instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public NettyChannelBuilder usePlaintext(boolean skipNegotiation) {
|
||||
if (skipNegotiation) {
|
||||
negotiationType(NegotiationType.PLAINTEXT);
|
||||
|
@ -237,6 +240,15 @@ public final class NettyChannelBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code PLAINTEXT}.
|
||||
*/
|
||||
@Override
|
||||
public NettyChannelBuilder usePlaintext() {
|
||||
negotiationType(NegotiationType.PLAINTEXT);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code TLS}.
|
||||
*/
|
||||
|
|
|
@ -273,7 +273,7 @@ public class OkHttpChannelBuilder extends
|
|||
* <p>By default {@link #DEFAULT_CONNECTION_SPEC} will be used.
|
||||
*
|
||||
* <p>This method is only used when building a secure connection. For plaintext
|
||||
* connection, use {@link #usePlaintext} instead.
|
||||
* connection, use {@link #usePlaintext()} instead.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If {@code connectionSpec} is not with TLS
|
||||
|
@ -286,8 +286,11 @@ public class OkHttpChannelBuilder extends
|
|||
|
||||
/**
|
||||
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code PLAINTEXT}.
|
||||
*
|
||||
* @deprecated use {@link #usePlaintext()} instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public final OkHttpChannelBuilder usePlaintext(boolean skipNegotiation) {
|
||||
if (skipNegotiation) {
|
||||
negotiationType(NegotiationType.PLAINTEXT);
|
||||
|
@ -297,6 +300,15 @@ public class OkHttpChannelBuilder extends
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code PLAINTEXT}.
|
||||
*/
|
||||
@Override
|
||||
public final OkHttpChannelBuilder usePlaintext() {
|
||||
negotiationType(NegotiationType.PLAINTEXT);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code TLS}.
|
||||
*/
|
||||
|
|
|
@ -108,14 +108,14 @@ public class OkHttpChannelBuilderTest {
|
|||
|
||||
@Test
|
||||
public void usePlaintext_newClientTransportAllowed() {
|
||||
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("host", 1234).usePlaintext(true);
|
||||
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("host", 1234).usePlaintext();
|
||||
builder.buildTransportFactory().newClientTransport(new InetSocketAddress(5678),
|
||||
"dummy_authority", "dummy_userAgent", null /* proxy */);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usePlaintextDefaultPort() {
|
||||
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("host", 1234).usePlaintext(true);
|
||||
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("host", 1234).usePlaintext();
|
||||
assertEquals(GrpcUtil.DEFAULT_PORT_PLAINTEXT,
|
||||
builder.getNameResolverParams().get(NameResolver.Factory.PARAMS_DEFAULT_PORT).intValue());
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class OkHttpChannelBuilderTest {
|
|||
OkHttpChannelBuilder builder = OkHttpChannelBuilder.forAddress("host", 1234);
|
||||
assertNotNull(builder.createSocketFactory());
|
||||
|
||||
builder.usePlaintext(true);
|
||||
builder.usePlaintext();
|
||||
assertNull(builder.createSocketFactory());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue