[ 
https://issues.apache.org/jira/browse/ARTEMIS-2323?focusedWorklogId=239404&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-239404
 ]

ASF GitHub Bot logged work on ARTEMIS-2323:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/May/19 18:55
            Start Date: 08/May/19 18:55
    Worklog Time Spent: 10m 
      Work Description: clebertsuconic commented on 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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 239404)
    Time Spent: 50m  (was: 40m)

> NettyTransport should also send requests with void promises
> -----------------------------------------------------------
>
>                 Key: ARTEMIS-2323
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2323
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>          Components: AMQP, STOMP
>    Affects Versions: 2.8.0
>            Reporter: Francesco Nigro
>            Assignee: Justin Bertram
>            Priority: Minor
>             Fix For: 2.8.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> AmqpConnection is using NettyTransport::send without making use of 
> ChannelFuture 
> return type, but NettyTcpTransport/NettyWSTransport always allocate a new 
> ChannelPromise
> on each call.
> If such ChannelFuture isn't needed (like STOMP does) it would be better to 
> avoid the ChannelPromise instantiation and enhance the API with a proper 
> method.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to