Skip to content

Commit 316a739

Browse files
authored
Revert "all: remove deprecated usePlaintext(boolean)"
This reverts commit 296857b.
1 parent 2c3ef87 commit 316a739

File tree

6 files changed

+83
-0
lines changed

6 files changed

+83
-0
lines changed

api/src/main/java/io/grpc/ForwardingChannelBuilder.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ public T overrideAuthority(String authority) {
9595
return thisT();
9696
}
9797

98+
/**
99+
* @deprecated use {@link #usePlaintext()} instead.
100+
*/
101+
@Override
102+
@Deprecated
103+
public T usePlaintext(boolean skipNegotiation) {
104+
delegate().usePlaintext(skipNegotiation);
105+
return thisT();
106+
}
107+
98108
@Override
99109
public T usePlaintext() {
100110
delegate().usePlaintext();

api/src/main/java/io/grpc/ManagedChannelBuilder.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,27 @@ public static ManagedChannelBuilder<?> forTarget(String target) {
150150
*/
151151
public abstract T overrideAuthority(String authority);
152152

153+
/**
154+
* Use of a plaintext connection to the server. By default a secure connection mechanism
155+
* such as TLS will be used.
156+
*
157+
* <p>Should only be used for testing or for APIs where the use of such API or the data
158+
* exchanged is not sensitive.
159+
*
160+
* @param skipNegotiation @{code true} if there is a priori knowledge that the endpoint supports
161+
* plaintext, {@code false} if plaintext use must be negotiated.
162+
* @deprecated Use {@link #usePlaintext()} instead.
163+
*
164+
* @throws UnsupportedOperationException if plaintext mode is not supported.
165+
* @return this
166+
* @since 1.0.0
167+
*/
168+
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1772")
169+
@Deprecated
170+
public T usePlaintext(boolean skipNegotiation) {
171+
throw new UnsupportedOperationException();
172+
}
173+
153174
/**
154175
* Use of a plaintext connection to the server. By default a secure connection mechanism
155176
* such as TLS will be used.

core/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ public InProcessChannelBuilder useTransportSecurity() {
9494
return this;
9595
}
9696

97+
/**
98+
* Does nothing.
99+
*
100+
* @deprecated use {@link #usePlaintext()} instead.
101+
*/
102+
@Override
103+
@Deprecated
104+
public InProcessChannelBuilder usePlaintext(boolean skipNegotiation) {
105+
return this;
106+
}
107+
97108
/**
98109
* Does nothing.
99110
*/

cronet/src/main/java/io/grpc/cronet/CronetChannelBuilder.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ public final CronetChannelBuilder alwaysUsePut(boolean enable) {
127127
return this;
128128
}
129129

130+
/**
131+
* Not supported for building cronet channel.
132+
*/
133+
@Override
134+
public final CronetChannelBuilder usePlaintext(boolean skipNegotiation) {
135+
throw new IllegalArgumentException("Plaintext not currently supported");
136+
}
137+
130138
/**
131139
* Sets {@link android.net.TrafficStats} tag to use when accounting socket traffic caused by this
132140
* channel. See {@link android.net.TrafficStats} for more information. If no tag is set (e.g. this

netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,23 @@ public NettyChannelBuilder maxInboundMetadataSize(int bytes) {
285285
return this;
286286
}
287287

288+
/**
289+
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code PLAINTEXT} or
290+
* {@code PLAINTEXT_UPGRADE}.
291+
*
292+
* @deprecated use {@link #usePlaintext()} instead.
293+
*/
294+
@Override
295+
@Deprecated
296+
public NettyChannelBuilder usePlaintext(boolean skipNegotiation) {
297+
if (skipNegotiation) {
298+
negotiationType(NegotiationType.PLAINTEXT);
299+
} else {
300+
negotiationType(NegotiationType.PLAINTEXT_UPGRADE);
301+
}
302+
return this;
303+
}
304+
288305
/**
289306
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code PLAINTEXT}.
290307
*/

okhttp/src/main/java/io/grpc/okhttp/OkHttpChannelBuilder.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,22 @@ public final OkHttpChannelBuilder connectionSpec(
305305
return this;
306306
}
307307

308+
/**
309+
* Equivalent to using {@link #negotiationType} with {@code PLAINTEXT}.
310+
*
311+
* @deprecated use {@link #usePlaintext()} instead.
312+
*/
313+
@Override
314+
@Deprecated
315+
public final OkHttpChannelBuilder usePlaintext(boolean skipNegotiation) {
316+
if (skipNegotiation) {
317+
negotiationType(io.grpc.okhttp.NegotiationType.PLAINTEXT);
318+
} else {
319+
throw new IllegalArgumentException("Plaintext negotiation not currently supported");
320+
}
321+
return this;
322+
}
323+
308324
/** Sets the negotiation type for the HTTP/2 connection to plaintext. */
309325
@Override
310326
public final OkHttpChannelBuilder usePlaintext() {

0 commit comments

Comments
 (0)