clebertsuconic commented on code in PR #4224:
URL: https://github.com/apache/activemq-artemis/pull/4224#discussion_r974320869
##########
artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/AbstractProducerCreditsImpl.java:
##########
@@ -144,24 +144,46 @@ public synchronized int decrementRefCount() {
protected void checkCredits(final int credits) {
int needed = Math.max(credits, windowSize);
+ if (logger.isTraceEnabled()) {
+ logger.tracef("CheckCredits %s on address %s, needed=%s, credits=%s,
window=%s", credits, address, needed, credits, windowSize);
+ }
int toRequest = -1;
synchronized (this) {
if (getBalance() + arriving < needed) {
toRequest = needed - arriving;
- pendingCredits += toRequest;
- arriving += toRequest;
+ if (logger.isTraceEnabled()) {
+ logger.tracef("CheckCredits on Address %s, requesting=%s,
arriving=%s, balance=%s", address, toRequest, arriving, getBalance());
+ }
+ } else {
+ if (logger.isTraceEnabled()) {
+ logger.tracef("CheckCredits did not need it, balance=%s,
arriving=%s, needed=%s, getbalance + arriving < needed=%s", getBalance(),
arriving, needed, (boolean)(getBalance() + arriving < needed));
+ }
}
}
- if (toRequest != -1) {
+ if (toRequest > 0) {
+ if (logger.isDebugEnabled()) {
+ logger.debugf("Requesting %s credits on address %s, needed = %s,
arriving = %s", toRequest, address, needed, arriving);
+ }
requestCredits(toRequest);
+ } else {
+ logger.debugf("not asking for %s credits on %s", toRequest, address);
}
}
- private void requestCredits(final int credits) {
+ @Override
+ public String toString() {
Review Comment:
hmmm... I did not mean to merge this line.. I will remove it.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]