Skip to content

Commit 695d8ce

Browse files
committed
chore(gax-grpc): replace magic number 5 with constant in ChannelPool
1 parent 808fa66 commit 695d8ce

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • sdk-platform-java/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc

sdk-platform-java/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class ChannelPool extends ManagedChannel {
8484
private final AtomicInteger indexTicker = new AtomicInteger();
8585
private final String authority;
8686

87+
// The number of consecutive resize cycles to wait before logging a warning about repeated resizing.
88+
// This is an arbitrary value chosen to detect potential thrashing without being too sensitive.
89+
private static final int CONSECUTIVE_RESIZE_THRESHOLD = 5;
90+
8791
// Tracks the number of consecutive resize cycles where a resize actually occurred (either expand or shrink).
8892
// Used to detect repeated resizing activity and log a warning.
8993
private int consecutiveResizes = 0;
@@ -331,7 +335,7 @@ void resize() {
331335
consecutiveResizes = 0;
332336
}
333337

334-
if (consecutiveResizes == 5) {
338+
if (consecutiveResizes == CONSECUTIVE_RESIZE_THRESHOLD) {
335339
LOG.warning(
336340
"Channel pool is repeatedly resizing. Consider adjusting `initialChannelCount` or `maxResizeDelta` to a more reasonable value. "
337341
+ "See https://docs.cloud.google.com/java/docs/troubleshooting to enable logging and set `com.google.api.gax.grpc.ChannelPool.level=FINEST` to log the channel pool resize behavior.");

0 commit comments

Comments
 (0)