我有一个netty身份验证处理程序,用于查看第一条消息(HttpRequest),
如果请求被授权,那么我就让处理程序在向上游发送消息之前从管道中删除它自己。但是,似乎下一条消息仍然是处理程序。这是预期的吗?
使用netty 4.14
public void channelRead(ChannelHandlerContext ctx, Object obj) throws Exception {
if (!(obj instanceof HttpRequest)) {
//Do not authenticate unknown object types.
ReferenceCountUtil.release(obj);
return;
}
HttpRequest httpRequest = (HttpRequest)obj;
AuthenticatedInfo authenticatedInfo = Services.authenticationAuthority.authenticate(httpRequest, null);
// check access
if (authenticatedInfo.getMerchantId() == null) {
sendUnauthorized(ctx);
ReferenceCountUtil.release(obj);
} else {
ctx.pipeline().remove(this);
ctx.fireChannelRead(httpRequest);
}
}