fix issue with assertion in HystrixStreamTests, polish diamond operator and follow class field naming convention (#2703)
* fix assertion check
* polish: replace the type specification in this constructor call with the diamond operator ("<>"),
make EUREKA_PACKAGES final to avoid issue "static non-final field names should comply with a naming convention"
This commit is contained in:
committed by
Ryan Baxter
parent
b2ebfc0ecb
commit
24dfd4ae76
@@ -38,7 +38,7 @@ public class ArchaiusEndpoint {
|
||||
|
||||
@ReadOperation
|
||||
public Map<String, Object> invoke() {
|
||||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
|
||||
if (config instanceof ConcurrentCompositeConfiguration) {
|
||||
ConcurrentCompositeConfiguration composite = (ConcurrentCompositeConfiguration) config;
|
||||
|
||||
@@ -157,7 +157,7 @@ public class FeignLoadBalancer extends
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
Map<String, List<String>> headers = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> headers = new HashMap<>();
|
||||
Map<String, Collection<String>> feignHeaders = RibbonRequest.this.toRequest().headers();
|
||||
for(String key : feignHeaders.keySet()) {
|
||||
headers.put(key, new ArrayList<String>(feignHeaders.get(key)));
|
||||
|
||||
@@ -83,7 +83,7 @@ public class FeignRetryPolicy extends InterceptorRetryPolicy {
|
||||
FeignRetryPolicyServiceInstance(String serviceId, HttpRequest request) {
|
||||
this.serviceId = serviceId;
|
||||
this.request = request;
|
||||
this.metadata = new HashMap<String, String>();
|
||||
this.metadata = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class HystrixHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Builder builder) throws Exception {
|
||||
List<String> openCircuitBreakers = new ArrayList<String>();
|
||||
List<String> openCircuitBreakers = new ArrayList<>();
|
||||
|
||||
// Collect all open circuit breakers from Hystrix
|
||||
for (HystrixCommandMetrics metrics : HystrixCommandMetrics.getInstances()) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MutableDiscoveryClientOptionalArgs extends DiscoveryClientOptionalA
|
||||
|
||||
@Override
|
||||
public void setAdditionalFilters(Collection<ClientFilter> additionalFilters) {
|
||||
additionalFilters = new LinkedHashSet<ClientFilter>(additionalFilters);
|
||||
additionalFilters = new LinkedHashSet<>(additionalFilters);
|
||||
this.additionalFilters = additionalFilters;
|
||||
super.setAdditionalFilters(additionalFilters);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class EurekaServerAutoConfiguration extends WebMvcConfigurerAdapter {
|
||||
/**
|
||||
* List of packages containing Jersey resources required by the Eureka server
|
||||
*/
|
||||
private static String[] EUREKA_PACKAGES = new String[] { "com.netflix.discovery",
|
||||
private static final String[] EUREKA_PACKAGES = new String[] { "com.netflix.discovery",
|
||||
"com.netflix.eureka" };
|
||||
|
||||
@Autowired
|
||||
@@ -283,7 +283,7 @@ public class EurekaServerAutoConfiguration extends WebMvcConfigurerAdapter {
|
||||
|
||||
// Find classes in Eureka packages (or subpackages)
|
||||
//
|
||||
Set<Class<?>> classes = new HashSet<Class<?>>();
|
||||
Set<Class<?>> classes = new HashSet<>();
|
||||
for (String basePackage : EUREKA_PACKAGES) {
|
||||
Set<BeanDefinition> beans = provider.findCandidateComponents(basePackage);
|
||||
for (BeanDefinition bd : beans) {
|
||||
@@ -295,7 +295,7 @@ public class EurekaServerAutoConfiguration extends WebMvcConfigurerAdapter {
|
||||
|
||||
// Construct the Jersey ResourceConfig
|
||||
//
|
||||
Map<String, Object> propsAndFeatures = new HashMap<String, Object>();
|
||||
Map<String, Object> propsAndFeatures = new HashMap<>();
|
||||
propsAndFeatures.put(
|
||||
// Skip static content used by the webapp
|
||||
ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX,
|
||||
|
||||
@@ -92,10 +92,10 @@ public class HystrixStreamTests {
|
||||
this.task.gatherMetrics();
|
||||
Message<?> message = this.collector.forChannel(output).take();
|
||||
JsonNode tree = mapper.readTree((String)message.getPayload());
|
||||
assertThat(tree.hasNonNull("origin"));
|
||||
assertThat(tree.hasNonNull("data"));
|
||||
assertThat(tree.hasNonNull("event"));
|
||||
assertThat(tree.findValue("event").asText().equals("message"));
|
||||
assertThat(tree.hasNonNull("origin")).isTrue();
|
||||
assertThat(tree.hasNonNull("data")).isTrue();
|
||||
assertThat(tree.hasNonNull("event")).isTrue();
|
||||
assertThat(tree.findValue("event").asText()).isEqualTo("message");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ZonePreferenceServerListFilter extends ZoneAffinityServerListFilter
|
||||
public List<Server> getFilteredListOfServers(List<Server> servers) {
|
||||
List<Server> output = super.getFilteredListOfServers(servers);
|
||||
if (this.zone != null && output.size() == servers.size()) {
|
||||
List<Server> local = new ArrayList<Server>();
|
||||
List<Server> local = new ArrayList<>();
|
||||
for (Server server : output) {
|
||||
if (this.zone.equalsIgnoreCase(server.getZone())) {
|
||||
local.add(server);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class RibbonRetryPolicy extends InterceptorRetryPolicy {
|
||||
RibbonRetryPolicyServiceInstance(String serviceId, HttpRequest request) {
|
||||
this.serviceId = serviceId;
|
||||
this.request = request;
|
||||
this.metadata = new HashMap<String, String>();
|
||||
this.metadata = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ public class TurbinePortApplicationListener implements
|
||||
return;
|
||||
}
|
||||
if (serverPort != Integer.valueOf(-1)) {
|
||||
Map<String, Object> ports = new HashMap<String, Object>();
|
||||
Map<String, Object> ports = new HashMap<>();
|
||||
if (turbinePort == null) {
|
||||
// The actual server.port used by the application forced to be -1 (no user
|
||||
// endpoints) because no value was provided for turbine
|
||||
|
||||
@@ -175,7 +175,7 @@ public class SimpleRouteLocator implements RouteLocator, Ordered {
|
||||
* {@link ZuulProperties}, but subclasses can add dynamic calculations.
|
||||
*/
|
||||
protected Map<String, ZuulRoute> locateRoutes() {
|
||||
LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>();
|
||||
LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<>();
|
||||
for (ZuulRoute route : this.properties.getRoutes().values()) {
|
||||
routesMap.put(route.getPath(), route);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class TraceProxyRequestHelper extends ProxyRequestHelper {
|
||||
if (this.traces != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> trace = (Map<String, Object>) info.get("headers");
|
||||
Map<String, Object> output = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> output = new LinkedHashMap<>();
|
||||
trace.put("response", output);
|
||||
debugHeaders(headers, output);
|
||||
output.put("status", "" + status);
|
||||
|
||||
@@ -99,10 +99,10 @@ public class DiscoveryClientRouteLocator extends SimpleRouteLocator
|
||||
|
||||
@Override
|
||||
protected LinkedHashMap<String, ZuulRoute> locateRoutes() {
|
||||
LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>();
|
||||
LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<>();
|
||||
routesMap.putAll(super.locateRoutes());
|
||||
if (this.discovery != null) {
|
||||
Map<String, ZuulRoute> staticServices = new LinkedHashMap<String, ZuulRoute>();
|
||||
Map<String, ZuulRoute> staticServices = new LinkedHashMap<>();
|
||||
for (ZuulRoute route : routesMap.values()) {
|
||||
String serviceId = route.getServiceId();
|
||||
if (serviceId == null) {
|
||||
|
||||
@@ -308,7 +308,7 @@ public class SimpleHostRoutingFilter extends ZuulFilter {
|
||||
}
|
||||
|
||||
private MultiValueMap<String, String> revertHeaders(Header[] headers) {
|
||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
|
||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
||||
for (Header header : headers) {
|
||||
String name = header.getName();
|
||||
if (!map.containsKey(name)) {
|
||||
|
||||
Reference in New Issue
Block a user