You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2019/05/08 18:55:51 UTC

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #2647: ARTEMIS-2323 NettyTransport should also send requests with void promises

clebertsuconic 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_r282202836
 
 

 ##########
 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:
   Are you doing this because you saw a high number of propmises being created by the default method?
   
   Looking at send (the one that's using channel.newPromise()) this is only used now in stomp, and even there it should be using sendVoidPromise i think.
   
   
   I'm not sure I understand what's the point of creating a promise if you're not using it. I thought it was the case.
   
   So, shouldn't all the sends be done without a promise (or with a void promise, which is like a static instance / singleton)?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services