File tree Expand file tree Collapse file tree 2 files changed +41
-13
lines changed
api/src/main/java/io/grpc
core/src/main/java/io/grpc/internal Expand file tree Collapse file tree 2 files changed +41
-13
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2026 The gRPC Authors
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package io .grpc ;
18+
19+ import com .google .common .base .Strings ;
20+
21+ @ Internal
22+ public class InternalFeatureFlags {
23+ public static boolean getFlag (String envVarName , boolean enableByDefault ) {
24+ String envVar = System .getenv (envVarName );
25+ if (envVar == null ) {
26+ envVar = System .getProperty (envVarName );
27+ }
28+ if (envVar != null ) {
29+ envVar = envVar .trim ();
30+ }
31+ if (enableByDefault ) {
32+ return Strings .isNullOrEmpty (envVar ) || Boolean .parseBoolean (envVar );
33+ } else {
34+ return !Strings .isNullOrEmpty (envVar ) && Boolean .parseBoolean (envVar );
35+ }
36+ }
37+
38+ private InternalFeatureFlags () {}
39+ }
Original file line number Diff line number Diff line change 2424import com .google .common .base .Preconditions ;
2525import com .google .common .base .Splitter ;
2626import com .google .common .base .Stopwatch ;
27- import com .google .common .base .Strings ;
2827import com .google .common .base .Supplier ;
2928import com .google .common .util .concurrent .ListenableFuture ;
3029import com .google .common .util .concurrent .ThreadFactoryBuilder ;
3130import io .grpc .CallOptions ;
3231import io .grpc .ClientStreamTracer ;
3332import io .grpc .ClientStreamTracer .StreamInfo ;
3433import io .grpc .InternalChannelz .SocketStats ;
34+ import io .grpc .InternalFeatureFlags ;
3535import io .grpc .InternalLogId ;
3636import io .grpc .InternalMetadata ;
3737import io .grpc .InternalMetadata .TrustedAsciiMarshaller ;
@@ -958,18 +958,7 @@ public static String encodeAuthority(String authority) {
958958 }
959959
960960 public static boolean getFlag (String envVarName , boolean enableByDefault ) {
961- String envVar = System .getenv (envVarName );
962- if (envVar == null ) {
963- envVar = System .getProperty (envVarName );
964- }
965- if (envVar != null ) {
966- envVar = envVar .trim ();
967- }
968- if (enableByDefault ) {
969- return Strings .isNullOrEmpty (envVar ) || Boolean .parseBoolean (envVar );
970- } else {
971- return !Strings .isNullOrEmpty (envVar ) && Boolean .parseBoolean (envVar );
972- }
961+ return InternalFeatureFlags .getFlag (envVarName , enableByDefault );
973962 }
974963
975964
You can’t perform that action at this time.
0 commit comments