Github user michaelandrepearce commented on the issue:

    https://github.com/apache/activemq-artemis/pull/1486
  
    @dudaerich agreed, essentially you're catching the case where enabled is 
changed between time the execute is called and its actually run, i think there 
maybe some possible tidy up could be done.
    
    currently:
    ```
          if (enabled) {
             replicationStream.execute(() -> {
                if (enabled) {
                   pendingTokens.add(repliToken);
                   flowControl(packet.expectedEncodeSize());
                   replicatingChannel.send(packet);
                } else {
                   packet.release();
                   repliToken.replicationDone();
                }
             });
          } else {
             // Already replicating channel failed, so just play the action now
             runItNow = true;
             packet.release();
          }
    
          // Execute outside lock
    
          if (runItNow) {
             repliToken.replicationDone();
          }
    ```
    
    as it seems the old lock that once existed is remove run it now can 
probably be removed and look like the same logic block inside you added to 
execute:
    
    e.g.
    ```
          if (enabled) {
             replicationStream.execute(() -> {
                if (enabled) {
                   pendingTokens.add(repliToken);
                   flowControl(packet.expectedEncodeSize());
                   replicatingChannel.send(packet);
                } else {
                   packet.release();
                   repliToken.replicationDone();
                }
             });
          } else {
             // Already replicating channel failed, so just play the action now
             packet.release();
             repliToken.replicationDone();
          }
    ```
    
    next is the question of do we need to have this duplicated check, could 
this just be all inside the runnable, do we need to do double check? e.g just 
have
    
    ```
    replicationStream.execute(() -> {
                if (enabled) {
                   pendingTokens.add(repliToken);
                   flowControl(packet.expectedEncodeSize());
                   replicatingChannel.send(packet);
                } else {
                   packet.release();
                   repliToken.replicationDone();
                }
             });
    ```



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to