Skip to content

Commit fb3805a

Browse files
committed
Removed redundant method
1 parent b61de62 commit fb3805a

File tree

2 files changed

+14
-30
lines changed

2 files changed

+14
-30
lines changed

xds/src/main/java/io/grpc/xds/GrpcBootstrapperImpl.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.grpc.CallCredentials;
2222
import io.grpc.ChannelCredentials;
2323
import io.grpc.CompositeCallCredentials;
24+
import io.grpc.CompositeChannelCredentials;
2425
import io.grpc.internal.GrpcUtil;
2526
import io.grpc.internal.JsonUtil;
2627
import io.grpc.xds.client.BootstrapperImpl;
@@ -98,9 +99,14 @@ protected String getJsonContent() throws XdsInitializationException, IOException
9899
}
99100

100101
@Override
101-
protected Object getImplSpecificChannelCredConfig(Map<String, ?> serverConfig, String serverUri)
102+
protected Object getImplSpecificConfig(Map<String, ?> serverConfig, String serverUri)
102103
throws XdsInitializationException {
103-
return getChannelCredentials(serverConfig, serverUri);
104+
ChannelCredentials channelCreds = getChannelCredentials(serverConfig, serverUri);
105+
CallCredentials callCreds = getCallCredentials(serverConfig, serverUri);
106+
if (callCreds != null) {
107+
channelCreds = CompositeChannelCredentials.create(channelCreds, callCreds);
108+
}
109+
return channelCreds;
104110
}
105111

106112
private static ChannelCredentials getChannelCredentials(Map<String, ?> serverConfig,
@@ -144,12 +150,6 @@ private static ChannelCredentials parseChannelCredentials(List<Map<String, ?>> j
144150
return null;
145151
}
146152

147-
@Override
148-
protected Object getImplSpecificCallCredConfig(Map<String, ?> serverConfig, String serverUri)
149-
throws XdsInitializationException {
150-
return getCallCredentials(serverConfig, serverUri);
151-
}
152-
153153
private static CallCredentials getCallCredentials(Map<String, ?> serverConfig,
154154
String serverUri)
155155
throws XdsInitializationException {

xds/src/main/java/io/grpc/xds/client/BootstrapperImpl.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
import com.google.common.annotations.VisibleForTesting;
2020
import com.google.common.collect.ImmutableList;
2121
import com.google.common.collect.ImmutableMap;
22-
import io.grpc.CallCredentials;
23-
import io.grpc.ChannelCredentials;
24-
import io.grpc.CompositeChannelCredentials;
2522
import io.grpc.Internal;
2623
import io.grpc.InternalLogId;
2724
import io.grpc.internal.GrpcUtil;
@@ -79,13 +76,9 @@ protected BootstrapperImpl() {
7976

8077
protected abstract String getJsonContent() throws IOException, XdsInitializationException;
8178

82-
protected abstract Object getImplSpecificChannelCredConfig(
83-
Map<String, ?> serverConfig, String serverUri)
79+
protected abstract Object getImplSpecificConfig(Map<String, ?> serverConfig, String serverUri)
8480
throws XdsInitializationException;
8581

86-
protected abstract Object getImplSpecificCallCredConfig(
87-
Map<String, ?> serverConfig, String serverUri)
88-
throws XdsInitializationException;
8982

9083
/**
9184
* Reads and parses bootstrap config. The config is expected to be in JSON format.
@@ -260,9 +253,7 @@ private List<ServerInfo> parseServerInfos(List<?> rawServerConfigs, XdsLogger lo
260253
}
261254
logger.log(XdsLogLevel.INFO, "xDS server URI: {0}", serverUri);
262255

263-
Object implSpecificChannelCredConfig =
264-
getImplSpecificChannelCredConfig(serverConfig, serverUri);
265-
Object implSpecificCallCredConfig = getImplSpecificCallCredConfig(serverConfig, serverUri);
256+
Object implSpecificConfig = getImplSpecificConfig(serverConfig, serverUri);
266257

267258
boolean resourceTimerIsTransientError = false;
268259
boolean ignoreResourceDeletion = false;
@@ -276,17 +267,10 @@ private List<ServerInfo> parseServerInfos(List<?> rawServerConfigs, XdsLogger lo
276267
&& serverFeatures.contains(SERVER_FEATURE_RESOURCE_TIMER_IS_TRANSIENT_ERROR);
277268
}
278269
servers.add(
279-
ServerInfo.create(
280-
serverUri,
281-
(implSpecificCallCredConfig != null)
282-
? CompositeChannelCredentials.create(
283-
(ChannelCredentials) implSpecificChannelCredConfig,
284-
(CallCredentials) implSpecificCallCredConfig)
285-
: implSpecificChannelCredConfig,
286-
ignoreResourceDeletion,
287-
serverFeatures != null
288-
&& serverFeatures.contains(SERVER_FEATURE_TRUSTED_XDS_SERVER),
289-
resourceTimerIsTransientError));
270+
ServerInfo.create(serverUri, implSpecificConfig, ignoreResourceDeletion,
271+
serverFeatures != null
272+
&& serverFeatures.contains(SERVER_FEATURE_TRUSTED_XDS_SERVER),
273+
resourceTimerIsTransientError));
290274
}
291275
return servers.build();
292276
}

0 commit comments

Comments
 (0)