Skip to content

Commit

Permalink
Suppress the errorprone warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Oct 1, 2019
1 parent 19f194d commit c27f772
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/reactor/netty/channel/MonoSendMany.java
Expand Up @@ -244,6 +244,7 @@ public void operationComplete(ChannelFuture future) {
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void run() {
Queue<I> queue = this.queue;
try {
Expand Down Expand Up @@ -274,6 +275,7 @@ public void run() {
continue;
}
pending++;
//"FutureReturnValueIgnored" this is deliberate
ctx.write(encodedMessage, this);

if (parent.flushOnEach || !ctx.channel().isWritable() || readableBytes > ctx.channel().bytesBeforeUnwritable()) {
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/reactor/netty/http/server/AccessLogHandler.java
Expand Up @@ -36,7 +36,7 @@ final class AccessLogHandler extends ChannelDuplexHandler {
AccessLog accessLog = new AccessLog();

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof HttpRequest) {
final HttpRequest request = (HttpRequest) msg;
final SocketChannel channel = (SocketChannel) ctx.channel();
Expand All @@ -48,16 +48,18 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
.uri(request.uri())
.protocol(request.protocolVersion().text());
}
super.channelRead(ctx, msg);
ctx.fireChannelRead(msg);
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
if (msg instanceof HttpResponse) {
final HttpResponse response = (HttpResponse) msg;
final HttpResponseStatus status = response.status();

if (status.equals(HttpResponseStatus.CONTINUE)) {
//"FutureReturnValueIgnored" this is deliberate
ctx.write(msg, promise);
return;
}
Expand Down Expand Up @@ -85,6 +87,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
if (msg instanceof ByteBufHolder) {
accessLog.increaseContentLength(((ByteBufHolder) msg).content().readableBytes());
}
//"FutureReturnValueIgnored" this is deliberate
ctx.write(msg, promise);
}
}
Expand Up @@ -32,7 +32,7 @@ final class AccessLogHandlerH2 extends ChannelDuplexHandler {
AccessLog accessLog = new AccessLog();

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof Http2HeadersFrame){
final Http2HeadersFrame requestHeaders = (Http2HeadersFrame) msg;
final SocketChannel channel = (SocketChannel) ctx.channel()
Expand All @@ -46,11 +46,12 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
.uri(headers.path())
.protocol(H2_PROTOCOL_NAME);
}
super.channelRead(ctx, msg);
ctx.fireChannelRead(msg);
}

@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
@SuppressWarnings("FutureReturnValueIgnored")
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
boolean lastContent = false;
if (msg instanceof Http2HeadersFrame) {
final Http2HeadersFrame responseHeaders = (Http2HeadersFrame) msg;
Expand All @@ -75,6 +76,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
});
return;
}
//"FutureReturnValueIgnored" this is deliberate
ctx.write(msg, promise);
}
}
Expand Up @@ -108,6 +108,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
if (msg instanceof Http2Headers) {
msg = new DefaultHttp2HeadersFrame((Http2Headers) msg);
Expand All @@ -124,6 +125,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
msg = new DefaultHttp2DataFrame((ByteBuf) msg);
}

//"FutureReturnValueIgnored" this is deliberate
ctx.write(msg, promise);
}

Expand Down
Expand Up @@ -219,6 +219,7 @@ void doPipeline(ChannelHandlerContext ctx, Object msg) {
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
// modify message on way out to add headers if needed
if (msg instanceof HttpResponse) {
Expand All @@ -236,6 +237,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}

if (response.status().equals(HttpResponseStatus.CONTINUE)) {
//"FutureReturnValueIgnored" this is deliberate
ctx.write(msg, promise);
return;
}
Expand Down Expand Up @@ -283,6 +285,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
}
return;
}
//"FutureReturnValueIgnored" this is deliberate
ctx.write(msg, promise);
}

Expand Down
Expand Up @@ -112,7 +112,9 @@ public io.netty.util.concurrent.Future<?> terminationFuture() {

@Deprecated
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void shutdown() {
//"FutureReturnValueIgnored" this is deliberate
shutdownGracefully();
}

Expand Down
Expand Up @@ -140,6 +140,7 @@ public EventLoopGroup onServerSelect(boolean useNative) {
return cacheNioSelectLoops();
}

@SuppressWarnings("FutureReturnValueIgnored")
EventLoopGroup cacheNioSelectLoops() {
if (serverSelectLoops == serverLoops) {
return cacheNioServerLoops();
Expand All @@ -150,6 +151,7 @@ EventLoopGroup cacheNioSelectLoops() {
EventLoopGroup newEventLoopGroup = new NioEventLoopGroup(selectCount,
threadFactory(this, "select-nio"));
if (!serverSelectLoops.compareAndSet(null, newEventLoopGroup)) {
//"FutureReturnValueIgnored" this is deliberate
newEventLoopGroup.shutdownGracefully();
}
eventLoopGroup = cacheNioSelectLoops();
Expand All @@ -165,12 +167,14 @@ public EventLoopGroup onServer(boolean useNative) {
return cacheNioServerLoops();
}

@SuppressWarnings("FutureReturnValueIgnored")
EventLoopGroup cacheNioServerLoops() {
EventLoopGroup eventLoopGroup = serverLoops.get();
if (null == eventLoopGroup) {
EventLoopGroup newEventLoopGroup = new NioEventLoopGroup(workerCount,
threadFactory(this, "nio"));
if (!serverLoops.compareAndSet(null, newEventLoopGroup)) {
//"FutureReturnValueIgnored" this is deliberate
newEventLoopGroup.shutdownGracefully();
}
eventLoopGroup = cacheNioServerLoops();
Expand Down Expand Up @@ -208,6 +212,7 @@ public String toString() {
'}';
}

@SuppressWarnings("FutureReturnValueIgnored")
EventLoopGroup cacheNativeSelectLoops() {
if (cacheNativeSelectLoops == cacheNativeServerLoops) {
return cacheNativeServerLoops();
Expand All @@ -220,13 +225,15 @@ EventLoopGroup cacheNativeSelectLoops() {
selectCount,
threadFactory(this, "select-" + defaultLoop.getName()));
if (!cacheNativeSelectLoops.compareAndSet(null, newEventLoopGroup)) {
//"FutureReturnValueIgnored" this is deliberate
newEventLoopGroup.shutdownGracefully();
}
eventLoopGroup = cacheNativeSelectLoops();
}
return eventLoopGroup;
}

@SuppressWarnings("FutureReturnValueIgnored")
EventLoopGroup cacheNativeServerLoops() {
EventLoopGroup eventLoopGroup = cacheNativeServerLoops.get();
if (null == eventLoopGroup) {
Expand All @@ -235,6 +242,7 @@ EventLoopGroup cacheNativeServerLoops() {
workerCount,
threadFactory(this, defaultLoop.getName()));
if (!cacheNativeServerLoops.compareAndSet(null, newEventLoopGroup)) {
//"FutureReturnValueIgnored" this is deliberate
newEventLoopGroup.shutdownGracefully();
}
eventLoopGroup = cacheNativeServerLoops();
Expand Down
Expand Up @@ -294,7 +294,7 @@ public void sendFileAsync4096Negative() throws IOException, URISyntaxException {
doTestSendFileAsync((req, resp) -> req.receive()
.take(10)
.doOnComplete(() -> resp.withConnection(c -> c.channel()
.close()))
.close())) //"FutureReturnValueIgnored" this is deliberate
.then(),
4096, "error".getBytes(Charset.defaultCharset()));
}
Expand Down

0 comments on commit c27f772

Please sign in to comment.