Skip to content

Commit

Permalink
Guard expensive log statement with an isInfoEnabled guard
Browse files Browse the repository at this point in the history
Behaviour is the same, but now disabling the logging of this statement
is a lot cheaper.

Signed-off-by: Niels Thykier <[email protected]>
  • Loading branch information
nt-gt committed Jan 26, 2024
1 parent 85a574d commit f172616
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ public void execute(

if (modifiedState != null) {
sortedPartitionsLockingMap.saveItem(lockedBy, partitionKey, sortKey, modifiedState);
int stateLength = modifiedState.toString().getBytes(StandardCharsets.UTF_8).length;
log.info(
"Max saved state length is now: %d"
.formatted(maxStateLength.accumulateAndGet(stateLength, Math::max)));
if (log.isInfoEnabled()) {
int stateLength = modifiedState.toString().getBytes(StandardCharsets.UTF_8).length;
log.info(
"Max saved state length is now: %d"
.formatted(maxStateLength.accumulateAndGet(stateLength, Math::max)));
}
} else {
sortedPartitionsLockingMap.unlockItem(lockedBy, partitionKey, sortKey);
}
Expand Down

0 comments on commit f172616

Please sign in to comment.