Add deprecation to Http2StreamChannelBootstrap.open0(...) as it was marked as public by mistake (#9372)

Motivation:

Mark Http2StreamChannelBootstrap.open0(...) as deprecated as the user should not use it. It was marked as public by mistake.

Modifications:

Add deprecation warning.

Result:

User will be aware the method should not be used directly.
This commit is contained in:
Norman Maurer 2019-07-16 13:08:09 +02:00
parent a136a38778
commit b0b02d51d2

View File

@ -91,16 +91,24 @@ public final class Http2StreamChannelBootstrap {
/** /**
* the {@link ChannelHandler} to use for serving the requests. * the {@link ChannelHandler} to use for serving the requests.
*/ */
@SuppressWarnings("unchecked")
public Http2StreamChannelBootstrap handler(ChannelHandler handler) { public Http2StreamChannelBootstrap handler(ChannelHandler handler) {
this.handler = requireNonNull(handler, "handler"); this.handler = requireNonNull(handler, "handler");
return this; return this;
} }
/**
* Open a new {@link Http2StreamChannel} to use.
* @return the {@link Future} that will be notified once the channel was opened successfully or it failed.
*/
public Future<Http2StreamChannel> open() { public Future<Http2StreamChannel> open() {
return open(channel.eventLoop().newPromise()); return open(channel.eventLoop().newPromise());
} }
/**
* Open a new {@link Http2StreamChannel} to use and notifies the given {@link Promise}.
* @return the {@link Future} that will be notified once the channel was opened successfully or it failed.
*/
@SuppressWarnings("deprecation")
public Future<Http2StreamChannel> open(final Promise<Http2StreamChannel> promise) { public Future<Http2StreamChannel> open(final Promise<Http2StreamChannel> promise) {
ChannelHandlerContext ctx = channel.pipeline().context(Http2MultiplexCodec.class); ChannelHandlerContext ctx = channel.pipeline().context(Http2MultiplexCodec.class);
if (ctx == null) { if (ctx == null) {
@ -125,6 +133,10 @@ public final class Http2StreamChannelBootstrap {
return promise; return promise;
} }
/**
* @deprecated should not be used directly. Use {@link #open()} or {@link #open(Promise)}
*/
@Deprecated
public void open0(ChannelHandlerContext ctx, final Promise<Http2StreamChannel> promise) { public void open0(ChannelHandlerContext ctx, final Promise<Http2StreamChannel> promise) {
assert ctx.executor().inEventLoop(); assert ctx.executor().inEventLoop();
final Http2StreamChannel streamChannel; final Http2StreamChannel streamChannel;
@ -167,7 +179,7 @@ public final class Http2StreamChannelBootstrap {
p.addLast(handler); p.addLast(handler);
} }
synchronized (options) { synchronized (options) {
setChannelOptions(channel, options, logger); setChannelOptions(channel, options);
} }
synchronized (attrs) { synchronized (attrs) {
@ -178,15 +190,15 @@ public final class Http2StreamChannelBootstrap {
} }
private static void setChannelOptions( private static void setChannelOptions(
Channel channel, Map<ChannelOption<?>, Object> options, InternalLogger logger) { Channel channel, Map<ChannelOption<?>, Object> options) {
for (Map.Entry<ChannelOption<?>, Object> e: options.entrySet()) { for (Map.Entry<ChannelOption<?>, Object> e: options.entrySet()) {
setChannelOption(channel, e.getKey(), e.getValue(), logger); setChannelOption(channel, e.getKey(), e.getValue());
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static void setChannelOption( private static void setChannelOption(
Channel channel, ChannelOption<?> option, Object value, InternalLogger logger) { Channel channel, ChannelOption<?> option, Object value) {
try { try {
if (!channel.config().setOption((ChannelOption<Object>) option, value)) { if (!channel.config().setOption((ChannelOption<Object>) option, value)) {
logger.warn("Unknown channel option '{}' for channel '{}'", option, channel); logger.warn("Unknown channel option '{}' for channel '{}'", option, channel);