Skip to content

Commit a5201b3

Browse files
AntonRoskvistjbertram
authored andcommitted
ARTEMIS-5733 Core bridge can lock on flow control
1 parent 8d6edcd commit a5201b3

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/AsynchronousProducerCreditsImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void receiveCredits(int credits) {
6666
}
6767
callback.onCreditsFlow(balance <= 0, this);
6868

69-
if (balance < 0 && arriving == 0) {
69+
if (balance <= 0 && arriving == 0) {
7070
// there are no more credits arriving and we are still negative, async large message send asked too much and we need to counter balance
7171
logger.debug("Starve credits counter balance");
7272
int request = -balance + windowSize * 2;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
* <p>
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
* <p>
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.activemq.artemis.core.client.impl;
19+
20+
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.Timeout;
22+
import org.mockito.Mockito;
23+
24+
public class AsynchronousProducerCreditsImplTest {
25+
26+
@Test
27+
@Timeout(10)
28+
public void testZeroCredits() throws Exception {
29+
ClientSessionInternal session = Mockito.mock(ClientSessionInternal.class);
30+
AsynchronousProducerCreditsImpl producerCredits = new AsynchronousProducerCreditsImpl(session, null, 0, Mockito.mock(ClientProducerFlowCallback.class));
31+
producerCredits.receiveCredits(0);
32+
Mockito.verify(session).sendProducerCreditsMessage(0, null);
33+
}
34+
35+
}

0 commit comments

Comments
 (0)