lhotari commented on code in PR #19141:
URL: https://github.com/apache/pulsar/pull/19141#discussion_r1065395253
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarCommandSenderImpl.java:
##########
@@ -377,7 +375,11 @@ public void sendWatchTopicListUpdate(long watcherId,
private void interceptAndWriteCommand(BaseCommand command) {
safeIntercept(command, cnx);
ByteBuf outBuf = Commands.serializeWithSize(command);
- cnx.ctx().writeAndFlush(outBuf);
+ writeAndFlushVoidPromise(outBuf);
+ }
+
+ private void writeAndFlushVoidPromise(ByteBuf outBuf) {
Review Comment:
```suggestion
private void writeAndFlush(ByteBuf outBuf) {
```
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/PulsarCommandSenderImpl.java:
##########
@@ -377,7 +375,11 @@ public void sendWatchTopicListUpdate(long watcherId,
private void interceptAndWriteCommand(BaseCommand command) {
safeIntercept(command, cnx);
ByteBuf outBuf = Commands.serializeWithSize(command);
- cnx.ctx().writeAndFlush(outBuf);
+ writeAndFlushVoidPromise(outBuf);
+ }
+
+ private void writeAndFlushVoidPromise(ByteBuf outBuf) {
+ NettyChannelUtil.writeAndFlushVoidPromise(cnx.ctx(), outBuf);
Review Comment:
```suggestion
NettyChannelUtil.writeAndFlushWithVoidPromise(cnx.ctx(), outBuf);
```
##########
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/PulsarDecoder.java:
##########
@@ -731,4 +739,8 @@ protected void
handleCommandWatchTopicListClose(CommandWatchTopicListClose comma
}
private static final Logger log =
LoggerFactory.getLogger(PulsarDecoder.class);
+
+ private void writeAndFlushVoidPromise(ChannelOutboundInvoker ctx, ByteBuf
cmd) {
Review Comment:
```suggestion
private void writeAndFlush(ChannelOutboundInvoker ctx, ByteBuf cmd) {
```
##########
pulsar-common/src/main/java/org/apache/pulsar/common/util/netty/NettyChannelUtil.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.common.util.netty;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelOutboundInvoker;
+
+/**
+ * Contains utility methods for working with Netty Channels.
+ */
+public class NettyChannelUtil {
+
+ public static void writeAndFlushVoidPromise(ChannelOutboundInvoker ctx,
ByteBuf cmd) {
Review Comment:
```suggestion
public static void writeAndFlushWithVoidPromise(ChannelOutboundInvoker
ctx, ByteBuf cmd) {
```
##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/LookupProxyHandler.java:
##########
@@ -446,5 +448,10 @@ private ServerError getServerError(Throwable error) {
return responseError;
}
+ private void writeAndFlushVoidPromise(ByteBuf cmd) {
Review Comment:
```suggestion
private void writeAndFlush(ByteBuf cmd) {
```
##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/LookupProxyHandler.java:
##########
@@ -446,5 +448,10 @@ private ServerError getServerError(Throwable error) {
return responseError;
}
+ private void writeAndFlushVoidPromise(ByteBuf cmd) {
+ final ChannelHandlerContext ctx = proxyConnection.ctx();
+ NettyChannelUtil.writeAndFlushVoidPromise(ctx, cmd);
Review Comment:
```suggestion
NettyChannelUtil.writeAndFlushWithVoidPromise(ctx, cmd);
```
##########
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/PulsarDecoder.java:
##########
@@ -731,4 +739,8 @@ protected void
handleCommandWatchTopicListClose(CommandWatchTopicListClose comma
}
private static final Logger log =
LoggerFactory.getLogger(PulsarDecoder.class);
+
+ private void writeAndFlushVoidPromise(ChannelOutboundInvoker ctx, ByteBuf
cmd) {
+ NettyChannelUtil.writeAndFlushVoidPromise(ctx, cmd);
Review Comment:
```suggestion
NettyChannelUtil.writeAndFlushWithVoidPromise(ctx, cmd);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]