From 96b6b018625ff05f94e79f582d4627461c1b44a8 Mon Sep 17 00:00:00 2001 From: MV Shiva Prasad Date: Tue, 10 Jun 2025 15:52:49 +0530 Subject: [PATCH 1/3] core: lazy error construction --- core/src/main/java/io/grpc/internal/InternalSubchannel.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/java/io/grpc/internal/InternalSubchannel.java b/core/src/main/java/io/grpc/internal/InternalSubchannel.java index 27a80f7c191..6f4dbe8ceab 100644 --- a/core/src/main/java/io/grpc/internal/InternalSubchannel.java +++ b/core/src/main/java/io/grpc/internal/InternalSubchannel.java @@ -345,6 +345,9 @@ private void gotoState(final ConnectivityStateInfo newState) { syncContext.throwIfNotInThisSynchronizationContext(); if (state.getState() != newState.getState()) { + if (state.getState() == SHUTDOWN) { + throw new IllegalArgumentException("Cannot transition out of SHUTDOWN to " + newState); + } Preconditions.checkState(state.getState() != SHUTDOWN, "Cannot transition out of SHUTDOWN to " + newState); if (reconnectDisabled && newState.getState() == TRANSIENT_FAILURE) { From bf2502eb861e9295cac05b8eab263691a970b7f9 Mon Sep 17 00:00:00 2001 From: MV Shiva Prasad Date: Tue, 10 Jun 2025 16:04:25 +0530 Subject: [PATCH 2/3] core: lazy error construction --- core/src/main/java/io/grpc/internal/InternalSubchannel.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/src/main/java/io/grpc/internal/InternalSubchannel.java b/core/src/main/java/io/grpc/internal/InternalSubchannel.java index 6f4dbe8ceab..9af87ea1925 100644 --- a/core/src/main/java/io/grpc/internal/InternalSubchannel.java +++ b/core/src/main/java/io/grpc/internal/InternalSubchannel.java @@ -348,8 +348,6 @@ private void gotoState(final ConnectivityStateInfo newState) { if (state.getState() == SHUTDOWN) { throw new IllegalArgumentException("Cannot transition out of SHUTDOWN to " + newState); } - Preconditions.checkState(state.getState() != SHUTDOWN, - "Cannot transition out of SHUTDOWN to " + newState); if (reconnectDisabled && newState.getState() == TRANSIENT_FAILURE) { state = ConnectivityStateInfo.forNonError(IDLE); } else { From 1791c12ce259b766f437360f110dc472546a126a Mon Sep 17 00:00:00 2001 From: MV Shiva Prasad Date: Thu, 12 Jun 2025 12:53:29 +0530 Subject: [PATCH 3/3] core: lazy error construction --- core/src/main/java/io/grpc/internal/InternalSubchannel.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/io/grpc/internal/InternalSubchannel.java b/core/src/main/java/io/grpc/internal/InternalSubchannel.java index 9af87ea1925..a27e46eaf60 100644 --- a/core/src/main/java/io/grpc/internal/InternalSubchannel.java +++ b/core/src/main/java/io/grpc/internal/InternalSubchannel.java @@ -345,9 +345,8 @@ private void gotoState(final ConnectivityStateInfo newState) { syncContext.throwIfNotInThisSynchronizationContext(); if (state.getState() != newState.getState()) { - if (state.getState() == SHUTDOWN) { - throw new IllegalArgumentException("Cannot transition out of SHUTDOWN to " + newState); - } + Preconditions.checkState(state.getState() != SHUTDOWN, + "Cannot transition out of SHUTDOWN to %s", newState.getState()); if (reconnectDisabled && newState.getState() == TRANSIENT_FAILURE) { state = ConnectivityStateInfo.forNonError(IDLE); } else {