xsd: Fix some lint errors. (#9159)

This commit is contained in:
Terry Wilson 2022-05-11 09:37:24 -07:00 committed by GitHub
parent 8f1dab0470
commit f68be9f87c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 16 deletions

View File

@ -57,7 +57,7 @@ import java.util.Map;
*/
class LoadBalancerConfigFactory {
private static XdsLogger logger = XdsLogger.withLogId(
private static final XdsLogger logger = XdsLogger.withLogId(
InternalLogId.allocate("xds-client-lbconfig-factory", null));
static final String ROUND_ROBIN_FIELD_NAME = "round_robin";
@ -87,7 +87,7 @@ class LoadBalancerConfigFactory {
return LoadBalancingPolicyConverter.convertToServiceConfig(cluster.getLoadBalancingPolicy(),
0);
} catch (MaxRecursionReachedException e) {
throw new ResourceInvalidException("Maximum LB config recursion depth reached");
throw new ResourceInvalidException("Maximum LB config recursion depth reached", e);
}
} else {
return LegacyLoadBalancingPolicyConverter.convertToServiceConfig(cluster, enableLeastRequest);
@ -195,7 +195,7 @@ class LoadBalancerConfigFactory {
* Converts a ring_hash {@link Any} configuration to service config format.
*/
private static ImmutableMap<String, ?> convertRingHashConfig(RingHash ringHash)
throws InvalidProtocolBufferException, ResourceInvalidException {
throws ResourceInvalidException {
// The hash function needs to be validated here as it is not exposed in the returned
// configuration for later validation.
if (RingHash.HashFunction.XX_HASH != ringHash.getHashFunction()) {
@ -212,7 +212,7 @@ class LoadBalancerConfigFactory {
* Converts a wrr_locality {@link Any} configuration to service config format.
*/
private static ImmutableMap<String, ?> convertWrrLocalityConfig(WrrLocality wrrLocality,
int recursionDepth) throws InvalidProtocolBufferException, ResourceInvalidException,
int recursionDepth) throws ResourceInvalidException,
MaxRecursionReachedException {
return buildWrrLocalityConfig(
convertToServiceConfig(wrrLocality.getEndpointPickingPolicy(), recursionDepth + 1));
@ -230,7 +230,7 @@ class LoadBalancerConfigFactory {
*/
@SuppressWarnings("unchecked")
private static ImmutableMap<String, ?> convertCustomConfig(TypedStruct configTypedStruct)
throws InvalidProtocolBufferException, ResourceInvalidException {
throws ResourceInvalidException {
Object rawJsonConfig = null;
try {
rawJsonConfig = JsonParser.parse(JsonFormat.printer().print(configTypedStruct.getValue()));

View File

@ -312,10 +312,9 @@ public class ClusterResolverLoadBalancerTest {
assertThat(wrrLocalityConfig.childPolicy.getProvider().getPolicyName()).isEqualTo(
"least_request_experimental");
Map<Locality, Integer> localityWeights = childBalancer.attributes.get(
InternalXdsAttributes.ATTR_LOCALITY_WEIGHTS);
assertThat(localityWeights).containsKey(locality1);
assertThat(localityWeights.get(locality1)).isEqualTo(100);
assertThat(
childBalancer.attributes.get(InternalXdsAttributes.ATTR_LOCALITY_WEIGHTS)).containsEntry(
locality1, 100);
}
@Test
@ -412,12 +411,9 @@ public class ClusterResolverLoadBalancerTest {
Map<Locality, Integer> localityWeights = childBalancer.attributes.get(
InternalXdsAttributes.ATTR_LOCALITY_WEIGHTS);
assertThat(localityWeights).containsKey(locality1);
assertThat(localityWeights.get(locality1)).isEqualTo(70);
assertThat(localityWeights).containsKey(locality2);
assertThat(localityWeights.get(locality2)).isEqualTo(10);
assertThat(localityWeights).containsKey(locality3);
assertThat(localityWeights.get(locality3)).isEqualTo(20);
assertThat(localityWeights).containsEntry(locality1, 70);
assertThat(localityWeights).containsEntry(locality2, 10);
assertThat(localityWeights).containsEntry(locality3, 20);
}
@Test

View File

@ -59,7 +59,7 @@ public class LoadBalancerConfigFactoryTest {
private static final Policy ROUND_ROBIN_POLICY = Policy.newBuilder().setTypedExtensionConfig(
TypedExtensionConfig.newBuilder().setTypedConfig(
Any.pack(RoundRobin.newBuilder().build()))).build();
Any.pack(RoundRobin.getDefaultInstance()))).build();
private static final long RING_HASH_MIN_RING_SIZE = 1;
private static final long RING_HASH_MAX_RING_SIZE = 2;