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

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

                Author: ASF GitHub Bot
            Created on: 28/Apr/26 18:19
            Start Date: 28/Apr/26 18:19
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on code in PR #6387:
URL: https://github.com/apache/artemis/pull/6387#discussion_r3156316722


##########
artemis-core-client/src/test/java/org/apache/activemq/artemis/core/client/impl/AsynchronousProducerCreditsImplTest.java:
##########
@@ -32,4 +38,51 @@ public void testZeroCredits() throws Exception {
       Mockito.verify(session).sendProducerCreditsMessage(0, null);
    }
 
+   @Test
+   @Timeout(10)
+   public void testCreditsRequestedWhenMessageSizeExactlyEqualsBalance() 
throws Exception {
+      ClientSessionInternal mockClientSession = 
Mockito.mock(ClientSessionInternal.class);
+
+      AtomicInteger creditsRequested = new AtomicInteger(0);
+      AtomicBoolean blocked = new AtomicBoolean(false);
+
+      int producerWindowSize = 1000;
+
+      Mockito.doAnswer(inv -> {
+         creditsRequested.addAndGet(inv.getArgument(0));
+         return null;
+      }).when(mockClientSession).sendProducerCreditsMessage(Mockito.anyInt(), 
Mockito.any());
+
+      AsynchronousProducerCreditsImpl producerCredits = new 
AsynchronousProducerCreditsImpl(mockClientSession, null, producerWindowSize, 
bridgeFlowCallback(blocked));

Review Comment:
   Instead of having the `private` `static` method I think this is a bit more 
clear:
   ```java
         AsynchronousProducerCreditsImpl producerCredits = new 
AsynchronousProducerCreditsImpl(mockClientSession, null, producerWindowSize, 
new ClientProducerFlowCallback() {
            @Override
            public void onCreditsFlow(boolean isBlocked, ClientProducerCredits 
credits) {
               blocked.set(isBlocked);
            }
   
            @Override
            public void onCreditsFail(ClientProducerCredits credits) {
            }
         });
   ```





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

    Worklog Id:     (was: 1017759)
    Time Spent: 20m  (was: 10m)

> Handle credit starvation affecting Core bridge
> ----------------------------------------------
>
>                 Key: ARTEMIS-6031
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-6031
>             Project: Artemis
>          Issue Type: Bug
>            Reporter: Anton Roskvist
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> This relates to ARTEMIS-5733 
> The fix in that case is still valid but turns out there was a similar thing 
> that could happen in "AbstractProducerCreditsImpl" as well.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to