Skip to content

Commit

Permalink
[FLINK-10075][rest] Addnull check before KeepAliveWrite.flush
Browse files Browse the repository at this point in the history
  • Loading branch information
azagrebin authored and zentol committed Oct 15, 2018
1 parent 4ff6483 commit be23889
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.flink.runtime.rest.handler.util.KeepAliveWrite;

import org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf;
import org.apache.flink.shaded.netty4.io.netty.channel.ChannelFutureListener;
import org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandlerContext;
import org.apache.flink.shaded.netty4.io.netty.channel.ChannelInboundHandlerAdapter;
import org.apache.flink.shaded.netty4.io.netty.handler.codec.ByteToMessageDecoder;
Expand Down Expand Up @@ -79,7 +80,7 @@ private void handleSsl(ChannelHandlerContext context) {
SslHandler sslHandler = new SslHandler(sslEngineFactory.createSSLEngine());
try {
context.pipeline().replace(this, SSL_HANDLER_NAME, sslHandler);
} catch (Throwable t){
} catch (Throwable t) {
ReferenceCountUtil.safeRelease(sslHandler.engine());
throw t;
}
Expand All @@ -94,7 +95,11 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
log.trace("Received non-SSL request, redirecting to {}{}", redirectAddress, path);
HttpResponse response = HandlerRedirectUtils.getRedirectResponse(
redirectAddress, path, HttpResponseStatus.MOVED_PERMANENTLY);
KeepAliveWrite.flush(ctx, request, response);
if (request != null) {
KeepAliveWrite.flush(ctx, request, response);
} else {
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
}

private String getRedirectAddress(ChannelHandlerContext ctx) throws Exception {
Expand Down

0 comments on commit be23889

Please sign in to comment.