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

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

                Author: ASF GitHub Bot
            Created on: 08/May/19 19:33
            Start Date: 08/May/19 19:33
    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_r282215861
 
 

 ##########
 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:
   I just looked further.. the only place this is being used is on client APIs 
on testing.
   
   
 
----------------------------------------------------------------
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: 239433)
    Time Spent: 1.5h  (was: 1h 20m)

> 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: 1.5h
>  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