diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AbstractConfigurationBuilder.java b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AbstractConfigurationBuilder.java index 378c1609af..59624a4cea 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AbstractConfigurationBuilder.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AbstractConfigurationBuilder.java @@ -23,6 +23,7 @@ import com.google.common.base.Strings; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeMap; @@ -204,7 +205,7 @@ public abstract class AbstractConfigurationBuilder } private static String commandLineFlag(Param param) { - String name = param.getName().toLowerCase(); + String name = param.getName().toLowerCase(Locale.ROOT); String type = (!param.getType().isEmpty() ? '=' + param.getType() : ""); return "--" + name + type; } diff --git a/core/src/main/java/io/grpc/internal/AutoConfiguredLoadBalancerFactory.java b/core/src/main/java/io/grpc/internal/AutoConfiguredLoadBalancerFactory.java index 6c476557d1..1e41dee497 100644 --- a/core/src/main/java/io/grpc/internal/AutoConfiguredLoadBalancerFactory.java +++ b/core/src/main/java/io/grpc/internal/AutoConfiguredLoadBalancerFactory.java @@ -189,7 +189,7 @@ public final class AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factor throws PolicyException { // Check for balancer addresses boolean haveBalancerAddress = false; - List backendAddrs = new ArrayList(); + List backendAddrs = new ArrayList<>(); for (EquivalentAddressGroup s : servers) { if (s.getAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null) { haveBalancerAddress = true; diff --git a/core/src/main/java/io/grpc/internal/ServiceConfigUtil.java b/core/src/main/java/io/grpc/internal/ServiceConfigUtil.java index 31312a45a8..4fd773f3cc 100644 --- a/core/src/main/java/io/grpc/internal/ServiceConfigUtil.java +++ b/core/src/main/java/io/grpc/internal/ServiceConfigUtil.java @@ -26,6 +26,7 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; @@ -320,7 +321,7 @@ public final class ServiceConfigUtil { "loadBalancingPolicy": "ROUND_ROBIN" // The deprecated policy key } */ - List> lbConfigs = new ArrayList>(); + List> lbConfigs = new ArrayList<>(); if (serviceConfig.containsKey(SERVICE_CONFIG_LOAD_BALANCING_CONFIG_KEY)) { List configs = getList(serviceConfig, SERVICE_CONFIG_LOAD_BALANCING_CONFIG_KEY); for (Object config : configs) { @@ -332,7 +333,7 @@ public final class ServiceConfigUtil { if (serviceConfig.containsKey(SERVICE_CONFIG_LOAD_BALANCING_POLICY_KEY)) { String policy = getString(serviceConfig, SERVICE_CONFIG_LOAD_BALANCING_POLICY_KEY); // Convert the policy to a config, so that the caller can handle them in the same way. - policy = policy.toLowerCase(); + policy = policy.toLowerCase(Locale.ROOT); Map fakeConfig = Collections.singletonMap(policy, (Object) Collections.emptyMap()); lbConfigs.add(fakeConfig); diff --git a/core/src/test/java/io/grpc/internal/AutoConfiguredLoadBalancerFactoryTest.java b/core/src/test/java/io/grpc/internal/AutoConfiguredLoadBalancerFactoryTest.java index a74a7fef4c..a7f9bd453a 100644 --- a/core/src/test/java/io/grpc/internal/AutoConfiguredLoadBalancerFactoryTest.java +++ b/core/src/test/java/io/grpc/internal/AutoConfiguredLoadBalancerFactoryTest.java @@ -399,7 +399,7 @@ public class AutoConfiguredLoadBalancerFactoryTest { assertThat(selection.provider).isInstanceOf(FakeRoundRobinLoadBalancerProvider.class); // Balancer addresses are filtered out in the server list passed to round_robin - assertThat(selection.serverList).isEqualTo(Collections.singletonList(servers.get(1))); + assertThat(selection.serverList).containsExactly(servers.get(1)); assertThat(selection.config).isNull(); verifyNoMoreInteractions(channelLogger); } @@ -424,7 +424,8 @@ public class AutoConfiguredLoadBalancerFactoryTest { lb.decideLoadBalancerProvider(servers, serviceConfig); fail("Should throw"); } catch (PolicyException e) { - assertThat(e.getMessage()) + assertThat(e) + .hasMessageThat() .isEqualTo("Received ONLY balancer addresses but grpclb runtime is missing"); } } @@ -433,7 +434,7 @@ public class AutoConfiguredLoadBalancerFactoryTest { public void decideLoadBalancerProvider_serviceConfigLbPolicyOverridesDefault() throws Exception { AutoConfiguredLoadBalancer lb = (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); - Map serviceConfig = new HashMap(); + Map serviceConfig = new HashMap<>(); serviceConfig.put("loadBalancingPolicy", "round_robin"); List servers = Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){})); @@ -466,7 +467,7 @@ public class AutoConfiguredLoadBalancerFactoryTest { public void decideLoadBalancerProvider_serviceConfigLbPolicyFailsOnUnknown() { AutoConfiguredLoadBalancer lb = (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); - Map serviceConfig = new HashMap(); + Map serviceConfig = new HashMap<>(); serviceConfig.put("loadBalancingPolicy", "MAGIC_BALANCER"); List servers = Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){})); @@ -474,7 +475,7 @@ public class AutoConfiguredLoadBalancerFactoryTest { lb.decideLoadBalancerProvider(servers, serviceConfig); fail(); } catch (PolicyException e) { - assertThat(e.getMessage()).isEqualTo( + assertThat(e).hasMessageThat().isEqualTo( "None of [magic_balancer] specified by Service Config are available."); } } @@ -491,7 +492,7 @@ public class AutoConfiguredLoadBalancerFactoryTest { lb.decideLoadBalancerProvider(servers, serviceConfig); fail(); } catch (PolicyException e) { - assertThat(e.getMessage()).isEqualTo( + assertThat(e).hasMessageThat().isEqualTo( "None of [magic_balancer] specified by Service Config are available."); } } diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/Http2Client.java b/interop-testing/src/main/java/io/grpc/testing/integration/Http2Client.java index 7a579e59b1..d5423c9071 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/Http2Client.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/Http2Client.java @@ -37,6 +37,7 @@ import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.logging.Level; @@ -368,7 +369,7 @@ public final class Http2Client { private static String validTestCasesHelpText() { StringBuilder builder = new StringBuilder(); for (Http2TestCases testCase : Http2TestCases.values()) { - String strTestcase = testCase.name().toLowerCase(); + String strTestcase = testCase.name().toLowerCase(Locale.ROOT); builder.append("\n ") .append(strTestcase) .append(": ")