franz1981 commented on a change in pull request #2647: ARTEMIS-2323
NettyTransport should also send requests with void promises
URL: https://github.com/apache/activemq-artemis/pull/2647#discussion_r282207969
##########
File path:
tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyTcpTransport.java
##########
@@ -222,17 +226,34 @@ public ByteBuf allocateSendBuffer(int size) throws
IOException {
return channel.alloc().ioBuffer(size, size);
}
- @Override
- public ChannelFuture send(ByteBuf output) throws IOException {
- checkConnected();
+ protected final ChannelFuture writeAndFlush(ByteBuf output,
+ ChannelPromise promise,
+ Function<? super ByteBuf, ?
extends ReferenceCounted> bufferTransformer) throws IOException {
+ try {
+ checkConnected();
+ } catch (IOException ioEx) {
+ output.release();
+ throw ioEx;
+ }
int length = output.readableBytes();
if (length == 0) {
+ output.release();
return null;
}
LOG.trace("Attempted write of: {} bytes", length);
- return channel.writeAndFlush(output);
+ return channel.writeAndFlush(bufferTransformer.apply(output), promise);
+ }
+
+ @Override
+ public ChannelFuture send(ByteBuf output) throws IOException {
+ return writeAndFlush(output, channel.newPromise(), identity());
+ }
+
+ @Override
+ public void sendVoidPromise(ByteBuf output) throws IOException {
+ writeAndFlush(output, channel.voidPromise(), identity());
Review comment:
Yes we can always use void primise as long as we don't need a callback: if
the callback is used void promise won't work
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services