GrpcChannelsProperties default scheme ignored / not used
The problem The GrpcChannelsProperties configuration class has a "defaultScheme" property that is configurable, but nothing is done with this configuration. As per the documentation:
If you don’t define an address it will be guessed:
- First it will try it with just it’s name (<name>)
- If you have configured a default scheme it will try that next (<scheme>:/<name>)
- Then it will use the default scheme of the NameResolver.Factory delegate (See the priorities above)
But this isn't correct. If there is no address configured for a client, then it will try with just its name, which will then use the default scheme of the NameResolver.Factory delegate. The default scheme in GrpcChannelsProperties is never used.
Each of the ChanelFactory implementations have the following code:
final GrpcChannelProperties properties = getPropertiesFor(name);
URI address = properties.getAddress();
if (address == null) {
address = URI.create(name);
}
The Solution ideally it would be something like:
final GrpcChannelProperties channelProperties = getPropertiesFor(name);
URI address = channelProperties.getAddress();
if (address == null) {
String defaultScheme = getProperties().getDefaultScheme();
if (defaultScheme != null) {
address = URI.create(defaultScheme + ":///" + name);
} else {
address = URI.create(name);
}
}
...
Yes, you are right. Contributions are welcome.
I opened a pull requests: https://github.com/yidongnan/grpc-spring-boot-starter/pull/687
Thanks, I will review it in a few days when I have some more time.
Fixed in #687