Cleanup and format code
This commit is contained in:
@@ -78,7 +78,7 @@ public class EndpointDocumentation {
|
||||
static final File LOG_FILE = new File("target/logs/spring.log");
|
||||
|
||||
private static final Set<String> SKIPPED = Collections
|
||||
.<String>unmodifiableSet(new HashSet<String>(
|
||||
.<String>unmodifiableSet(new HashSet<>(
|
||||
Arrays.asList("/docs", "/logfile", "/heapdump", "/auditevents")));
|
||||
|
||||
@Autowired
|
||||
@@ -161,8 +161,8 @@ public class EndpointDocumentation {
|
||||
@Test
|
||||
public void endpoints() throws Exception {
|
||||
final File docs = new File("src/main/asciidoc");
|
||||
final Map<String, Object> model = new LinkedHashMap<String, Object>();
|
||||
final List<EndpointDoc> endpoints = new ArrayList<EndpointDoc>();
|
||||
final Map<String, Object> model = new LinkedHashMap<>();
|
||||
final List<EndpointDoc> endpoints = new ArrayList<>();
|
||||
model.put("endpoints", endpoints);
|
||||
for (MvcEndpoint endpoint : getEndpoints()) {
|
||||
final String endpointPath = (StringUtils.hasText(endpoint.getPath())
|
||||
@@ -200,7 +200,7 @@ public class EndpointDocumentation {
|
||||
}
|
||||
|
||||
private Collection<? extends MvcEndpoint> getEndpoints() {
|
||||
List<? extends MvcEndpoint> endpoints = new ArrayList<MvcEndpoint>(
|
||||
List<? extends MvcEndpoint> endpoints = new ArrayList<>(
|
||||
this.mvcEndpoints.getEndpoints());
|
||||
Collections.sort(endpoints, new Comparator<MvcEndpoint>() {
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,8 +39,8 @@ public class LimitedEnvironmentEndpoint extends EnvironmentEndpoint {
|
||||
private static final MultiValueMap<String, String> INCLUDES;
|
||||
|
||||
static {
|
||||
Map<String, List<String>> includes = new LinkedHashMap<String, List<String>>();
|
||||
List<String> systemProperties = new ArrayList<String>();
|
||||
Map<String, List<String>> includes = new LinkedHashMap<>();
|
||||
List<String> systemProperties = new ArrayList<>();
|
||||
systemProperties.add("java.runtime.name");
|
||||
systemProperties.add("sun.boot.library.path");
|
||||
systemProperties.add("java.vendor.url");
|
||||
@@ -61,14 +61,13 @@ public class LimitedEnvironmentEndpoint extends EnvironmentEndpoint {
|
||||
systemProperties.add("java.vendor");
|
||||
systemProperties.add("file.separator");
|
||||
includes.put("systemProperties", systemProperties);
|
||||
List<String> systemEnvironment = new ArrayList<String>();
|
||||
List<String> systemEnvironment = new ArrayList<>();
|
||||
systemEnvironment.add("SHELL");
|
||||
systemEnvironment.add("TMPDIR");
|
||||
systemEnvironment.add("DISPLAY");
|
||||
systemEnvironment.add("LOGNAME");
|
||||
includes.put("systemEnvironment", systemEnvironment);
|
||||
INCLUDES = new LinkedMultiValueMap<String, String>(
|
||||
Collections.unmodifiableMap(includes));
|
||||
INCLUDES = new LinkedMultiValueMap<>(Collections.unmodifiableMap(includes));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -94,7 +94,7 @@ public class AuditEvent implements Serializable {
|
||||
}
|
||||
|
||||
private static Map<String, Object> convert(String[] data) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
for (String entry : data) {
|
||||
if (entry.contains("=")) {
|
||||
int index = entry.indexOf("=");
|
||||
|
||||
@@ -81,7 +81,7 @@ public class InMemoryAuditEventRepository implements AuditEventRepository {
|
||||
|
||||
@Override
|
||||
public List<AuditEvent> find(String principal, Date after, String type) {
|
||||
LinkedList<AuditEvent> events = new LinkedList<AuditEvent>();
|
||||
LinkedList<AuditEvent> events = new LinkedList<>();
|
||||
synchronized (this.monitor) {
|
||||
for (int i = 0; i < this.events.length; i++) {
|
||||
AuditEvent event = resolveTailEvent(i);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -145,7 +145,7 @@ public class EndpointAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MetricsEndpoint metricsEndpoint() {
|
||||
List<PublicMetrics> publicMetrics = new ArrayList<PublicMetrics>();
|
||||
List<PublicMetrics> publicMetrics = new ArrayList<>();
|
||||
if (this.publicMetrics != null) {
|
||||
publicMetrics.addAll(this.publicMetrics);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,23 +34,23 @@ public class EndpointCorsProperties {
|
||||
* Comma-separated list of origins to allow. '*' allows all origins. When not set,
|
||||
* CORS support is disabled.
|
||||
*/
|
||||
private List<String> allowedOrigins = new ArrayList<String>();
|
||||
private List<String> allowedOrigins = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Comma-separated list of methods to allow. '*' allows all methods. When not set,
|
||||
* defaults to GET.
|
||||
*/
|
||||
private List<String> allowedMethods = new ArrayList<String>();
|
||||
private List<String> allowedMethods = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Comma-separated list of headers to allow in a request. '*' allows all headers.
|
||||
*/
|
||||
private List<String> allowedHeaders = new ArrayList<String>();
|
||||
private List<String> allowedHeaders = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Comma-separated list of headers to include in a response.
|
||||
*/
|
||||
private List<String> exposedHeaders = new ArrayList<String>();
|
||||
private List<String> exposedHeaders = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Set whether credentials are supported. When not set, credentials are not supported.
|
||||
|
||||
@@ -243,7 +243,7 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||
}
|
||||
|
||||
private List<HandlerMapping> extractMappings() {
|
||||
List<HandlerMapping> list = new ArrayList<HandlerMapping>();
|
||||
List<HandlerMapping> list = new ArrayList<>();
|
||||
list.addAll(this.beanFactory.getBeansOfType(HandlerMapping.class).values());
|
||||
list.remove(this);
|
||||
AnnotationAwareOrderComparator.sort(list);
|
||||
@@ -260,7 +260,7 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||
private List<HandlerAdapter> adapters;
|
||||
|
||||
private List<HandlerAdapter> extractAdapters() {
|
||||
List<HandlerAdapter> list = new ArrayList<HandlerAdapter>();
|
||||
List<HandlerAdapter> list = new ArrayList<>();
|
||||
list.addAll(this.beanFactory.getBeansOfType(HandlerAdapter.class).values());
|
||||
list.remove(this);
|
||||
AnnotationAwareOrderComparator.sort(list);
|
||||
@@ -317,7 +317,7 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||
private List<HandlerExceptionResolver> resolvers;
|
||||
|
||||
private List<HandlerExceptionResolver> extractResolvers() {
|
||||
List<HandlerExceptionResolver> list = new ArrayList<HandlerExceptionResolver>();
|
||||
List<HandlerExceptionResolver> list = new ArrayList<>();
|
||||
list.addAll(this.beanFactory.getBeansOfType(HandlerExceptionResolver.class)
|
||||
.values());
|
||||
list.remove(this);
|
||||
|
||||
@@ -126,8 +126,8 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
|
||||
@ConditionalOnBean(DocsMvcEndpoint.class)
|
||||
@ConditionalOnMissingBean(CurieProvider.class)
|
||||
@ConditionalOnProperty(prefix = "endpoints.docs.curies", name = "enabled", matchIfMissing = false)
|
||||
public DefaultCurieProvider curieProvider(
|
||||
ManagementServerProperties management, DocsMvcEndpoint endpoint) {
|
||||
public DefaultCurieProvider curieProvider(ManagementServerProperties management,
|
||||
DocsMvcEndpoint endpoint) {
|
||||
String path = management.getContextPath() + endpoint.getPath()
|
||||
+ "/#spring_boot_actuator__{rel}";
|
||||
return new DefaultCurieProvider("boot", new UriTemplate(path));
|
||||
@@ -229,7 +229,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
|
||||
|
||||
private final List<RequestMappingHandlerAdapter> handlerAdapters;
|
||||
|
||||
private final Map<MediaType, HttpMessageConverter<?>> converterCache = new ConcurrentHashMap<MediaType, HttpMessageConverter<?>>();
|
||||
private final Map<MediaType, HttpMessageConverter<?>> converterCache = new ConcurrentHashMap<>();
|
||||
|
||||
MvcEndpointAdvice(List<RequestMappingHandlerAdapter> handlerAdapters) {
|
||||
this.handlerAdapters = handlerAdapters;
|
||||
@@ -248,7 +248,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
|
||||
private void configureHttpMessageConverter(
|
||||
HttpMessageConverter<?> messageConverter) {
|
||||
if (messageConverter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
|
||||
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
|
||||
List<MediaType> supportedMediaTypes = new ArrayList<>(
|
||||
messageConverter.getSupportedMediaTypes());
|
||||
supportedMediaTypes.add(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON);
|
||||
((AbstractHttpMessageConverter<?>) messageConverter)
|
||||
|
||||
@@ -201,7 +201,7 @@ public class HealthIndicatorAutoConfiguration {
|
||||
if (candidates == null) {
|
||||
return null;
|
||||
}
|
||||
Map<String, DataSource> dataSources = new LinkedHashMap<String, DataSource>();
|
||||
Map<String, DataSource> dataSources = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, DataSource> entry : candidates.entrySet()) {
|
||||
if (!(entry.getValue() instanceof AbstractRoutingDataSource)) {
|
||||
dataSources.put(entry.getKey(), entry.getValue());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ public class HealthMvcEndpointProperties {
|
||||
* Mapping of health statuses to HttpStatus codes. By default, registered health
|
||||
* statuses map to sensible defaults (i.e. UP maps to 200).
|
||||
*/
|
||||
private Map<String, HttpStatus> mapping = new HashMap<String, HttpStatus>();
|
||||
private Map<String, HttpStatus> mapping = new HashMap<>();
|
||||
|
||||
public Map<String, HttpStatus> getMapping() {
|
||||
return this.mapping;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ public class JolokiaProperties {
|
||||
* Jolokia settings. These are traditionally set using servlet parameters. Refer to
|
||||
* the documentation of Jolokia for more details.
|
||||
*/
|
||||
private Map<String, String> config = new HashMap<String, String>();
|
||||
private Map<String, String> config = new HashMap<>();
|
||||
|
||||
public Map<String, String> getConfig() {
|
||||
return this.config;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ class LinksEnhancer {
|
||||
resource.add(linkTo(LinksEnhancer.class).slash(this.rootPath + self)
|
||||
.withSelfRel());
|
||||
}
|
||||
MultiValueMap<String, String> added = new LinkedMultiValueMap<String, String>();
|
||||
MultiValueMap<String, String> added = new LinkedMultiValueMap<>();
|
||||
for (MvcEndpoint endpoint : this.endpoints.getEndpoints()) {
|
||||
if (!endpoint.getPath().equals(self)) {
|
||||
String rel = getRel(endpoint);
|
||||
|
||||
@@ -53,7 +53,7 @@ class ManagementContextConfigurationsImportSelector
|
||||
// Find all management context configuration classes, filtering duplicates
|
||||
List<ManagementConfiguration> configurations = getConfigurations();
|
||||
OrderComparator.sort(configurations);
|
||||
List<String> names = new ArrayList<String>();
|
||||
List<String> names = new ArrayList<>();
|
||||
for (ManagementConfiguration configuration : configurations) {
|
||||
names.add(configuration.getClassName());
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class ManagementContextConfigurationsImportSelector
|
||||
private List<ManagementConfiguration> getConfigurations() {
|
||||
SimpleMetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory(
|
||||
this.classLoader);
|
||||
List<ManagementConfiguration> configurations = new ArrayList<ManagementConfiguration>();
|
||||
List<ManagementConfiguration> configurations = new ArrayList<>();
|
||||
for (String className : loadFactoryNames()) {
|
||||
getConfiguration(readerFactory, configurations, className);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ public class ManagementWebSecurityAutoConfiguration {
|
||||
return NO_PATHS;
|
||||
}
|
||||
Set<? extends MvcEndpoint> endpoints = endpointHandlerMapping.getEndpoints();
|
||||
Set<String> paths = new LinkedHashSet<String>(endpoints.size());
|
||||
Set<String> paths = new LinkedHashSet<>(endpoints.size());
|
||||
for (MvcEndpoint endpoint : endpoints) {
|
||||
if (isIncluded(endpoint)) {
|
||||
String path = endpointHandlerMapping.getPath(endpoint.getPath());
|
||||
@@ -361,10 +361,11 @@ public class ManagementWebSecurityAutoConfiguration {
|
||||
private RequestMatcher createDelegate() {
|
||||
ServerProperties server = this.contextResolver.getApplicationContext()
|
||||
.getBean(ServerProperties.class);
|
||||
List<RequestMatcher> matchers = new ArrayList<RequestMatcher>();
|
||||
List<RequestMatcher> matchers = new ArrayList<>();
|
||||
EndpointHandlerMapping endpointHandlerMapping = getRequiredEndpointHandlerMapping();
|
||||
for (String path : this.endpointPaths.getPaths(endpointHandlerMapping)) {
|
||||
matchers.add(new AntPathRequestMatcher(server.getServlet().getPath(path)));
|
||||
matchers.add(
|
||||
new AntPathRequestMatcher(server.getServlet().getPath(path)));
|
||||
}
|
||||
return (matchers.isEmpty() ? MATCH_NONE : new OrRequestMatcher(matchers));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -78,7 +78,7 @@ public class MetricExportAutoConfiguration {
|
||||
@ConditionalOnMissingBean(name = "metricWritersMetricExporter")
|
||||
public SchedulingConfigurer metricWritersMetricExporter(
|
||||
MetricExportProperties properties) {
|
||||
Map<String, GaugeWriter> writers = new HashMap<String, GaugeWriter>();
|
||||
Map<String, GaugeWriter> writers = new HashMap<>();
|
||||
MetricReader reader = this.endpointReader;
|
||||
if (reader == null && !CollectionUtils.isEmpty(this.readers)) {
|
||||
reader = new CompositeMetricReader(
|
||||
|
||||
@@ -43,9 +43,8 @@ public class MetricFilterProperties {
|
||||
private Set<MetricsFilterSubmission> counterSubmissions;
|
||||
|
||||
public MetricFilterProperties() {
|
||||
this.gaugeSubmissions = new HashSet<MetricsFilterSubmission>(
|
||||
EnumSet.of(MetricsFilterSubmission.MERGED));
|
||||
this.counterSubmissions = new HashSet<MetricsFilterSubmission>(
|
||||
this.gaugeSubmissions = new HashSet<>(EnumSet.of(MetricsFilterSubmission.MERGED));
|
||||
this.counterSubmissions = new HashSet<>(
|
||||
EnumSet.of(MetricsFilterSubmission.MERGED));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ final class MetricsFilter extends OncePerRequestFilter {
|
||||
private static final Set<PatternReplacer> STATUS_REPLACERS;
|
||||
|
||||
static {
|
||||
Set<PatternReplacer> replacements = new LinkedHashSet<PatternReplacer>();
|
||||
Set<PatternReplacer> replacements = new LinkedHashSet<>();
|
||||
replacements.add(new PatternReplacer("\\{(.+?)(?::.+)?\\}", 0, "-$1-"));
|
||||
replacements.add(new PatternReplacer("**", Pattern.LITERAL, "-star-star-"));
|
||||
replacements.add(new PatternReplacer("*", Pattern.LITERAL, "-star-"));
|
||||
@@ -77,7 +77,7 @@ final class MetricsFilter extends OncePerRequestFilter {
|
||||
private static final Set<PatternReplacer> KEY_REPLACERS;
|
||||
|
||||
static {
|
||||
Set<PatternReplacer> replacements = new LinkedHashSet<PatternReplacer>();
|
||||
Set<PatternReplacer> replacements = new LinkedHashSet<>();
|
||||
replacements.add(new PatternReplacer("/", Pattern.LITERAL, "."));
|
||||
replacements.add(new PatternReplacer("..", Pattern.LITERAL, "."));
|
||||
KEY_REPLACERS = Collections.unmodifiableSet(replacements);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public abstract class AbstractJmxCacheStatisticsProvider<C extends Cache>
|
||||
|
||||
private MBeanServer mBeanServer;
|
||||
|
||||
private final Map<String, ObjectNameWrapper> caches = new ConcurrentHashMap<String, ObjectNameWrapper>();
|
||||
private final Map<String, ObjectNameWrapper> caches = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public CacheStatistics getCacheStatistics(CacheManager cacheManager, C cache) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ public class DefaultCacheStatistics implements CacheStatistics {
|
||||
|
||||
@Override
|
||||
public Collection<Metric<?>> toMetrics(String prefix) {
|
||||
Collection<Metric<?>> result = new ArrayList<Metric<?>>();
|
||||
Collection<Metric<?>> result = new ArrayList<>();
|
||||
addMetric(result, prefix + "size", getSize());
|
||||
addMetric(result, prefix + "hit.ratio", getHitRatio());
|
||||
addMetric(result, prefix + "miss.ratio", getMissRatio());
|
||||
@@ -83,7 +83,7 @@ public class DefaultCacheStatistics implements CacheStatistics {
|
||||
private <T extends Number> void addMetric(Collection<Metric<?>> metrics, String name,
|
||||
T value) {
|
||||
if (value != null) {
|
||||
metrics.add(new Metric<T>(name, value));
|
||||
metrics.add(new Metric<>(name, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,7 +60,7 @@ public class CloudFoundryActuatorAutoConfiguration {
|
||||
public CloudFoundryEndpointHandlerMapping cloudFoundryEndpointHandlerMapping(
|
||||
MvcEndpoints mvcEndpoints, RestTemplateBuilder restTemplateBuilder,
|
||||
Environment environment) {
|
||||
Set<NamedMvcEndpoint> endpoints = new LinkedHashSet<NamedMvcEndpoint>(
|
||||
Set<NamedMvcEndpoint> endpoints = new LinkedHashSet<>(
|
||||
mvcEndpoints.getEndpoints(NamedMvcEndpoint.class));
|
||||
HandlerInterceptor securityInterceptor = getSecurityInterceptor(
|
||||
restTemplateBuilder, environment);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,7 +48,7 @@ class CloudFoundryDiscoveryMvcEndpoint extends AbstractMvcEndpoint {
|
||||
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public Map<String, Map<String, Link>> links(HttpServletRequest request) {
|
||||
Map<String, Link> links = new LinkedHashMap<String, Link>();
|
||||
Map<String, Link> links = new LinkedHashMap<>();
|
||||
String url = request.getRequestURL().toString();
|
||||
if (url.endsWith("/")) {
|
||||
url = url.substring(0, url.length() - 1);
|
||||
|
||||
@@ -116,7 +116,7 @@ class CloudFoundrySecurityService {
|
||||
}
|
||||
|
||||
private Map<String, String> extractTokenKeys(Map<?, ?> response) {
|
||||
Map<String, String> tokenKeys = new HashMap<String, String>();
|
||||
Map<String, String> tokenKeys = new HashMap<>();
|
||||
for (Object key : (List<?>) response.get("keys")) {
|
||||
Map<?, ?> tokenKey = (Map<?, ?>) key;
|
||||
tokenKeys.put((String) tokenKey.get("kid"), (String) tokenKey.get("value"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,8 +77,8 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
|
||||
private final Report parent;
|
||||
|
||||
public Report(ConditionEvaluationReport report) {
|
||||
this.positiveMatches = new LinkedMultiValueMap<String, MessageAndCondition>();
|
||||
this.negativeMatches = new LinkedHashMap<String, MessageAndConditions>();
|
||||
this.positiveMatches = new LinkedMultiValueMap<>();
|
||||
this.negativeMatches = new LinkedHashMap<>();
|
||||
this.exclusions = report.getExclusions();
|
||||
for (Map.Entry<String, ConditionAndOutcomes> entry : report
|
||||
.getConditionAndOutcomesBySource().entrySet()) {
|
||||
@@ -131,9 +131,9 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
|
||||
@JsonPropertyOrder({ "notMatched", "matched" })
|
||||
public static class MessageAndConditions {
|
||||
|
||||
private final List<MessageAndCondition> notMatched = new ArrayList<MessageAndCondition>();
|
||||
private final List<MessageAndCondition> notMatched = new ArrayList<>();
|
||||
|
||||
private final List<MessageAndCondition> matched = new ArrayList<MessageAndCondition>();
|
||||
private final List<MessageAndCondition> matched = new ArrayList<>();
|
||||
|
||||
public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) {
|
||||
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class BeansEndpoint extends AbstractEndpoint<List<Object>>
|
||||
}
|
||||
|
||||
private Set<ConfigurableApplicationContext> getContextHierarchy() {
|
||||
Set<ConfigurableApplicationContext> contexts = new LinkedHashSet<ConfigurableApplicationContext>();
|
||||
Set<ConfigurableApplicationContext> contexts = new LinkedHashSet<>();
|
||||
ApplicationContext context = this.leafContext;
|
||||
while (context != null) {
|
||||
contexts.add(asConfigurableContext(context));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,7 +47,7 @@ public class CachePublicMetrics implements PublicMetrics {
|
||||
|
||||
@Override
|
||||
public Collection<Metric<?>> metrics() {
|
||||
Collection<Metric<?>> metrics = new HashSet<Metric<?>>();
|
||||
Collection<Metric<?>> metrics = new HashSet<>();
|
||||
for (Map.Entry<String, List<CacheManagerBean>> entry : getCacheManagerBeans()
|
||||
.entrySet()) {
|
||||
addMetrics(metrics, entry.getKey(), entry.getValue());
|
||||
@@ -56,7 +56,7 @@ public class CachePublicMetrics implements PublicMetrics {
|
||||
}
|
||||
|
||||
private MultiValueMap<String, CacheManagerBean> getCacheManagerBeans() {
|
||||
MultiValueMap<String, CacheManagerBean> cacheManagerNamesByCacheName = new LinkedMultiValueMap<String, CacheManagerBean>();
|
||||
MultiValueMap<String, CacheManagerBean> cacheManagerNamesByCacheName = new LinkedMultiValueMap<>();
|
||||
for (Map.Entry<String, CacheManager> entry : this.cacheManagers.entrySet()) {
|
||||
for (String cacheName : entry.getValue().getCacheNames()) {
|
||||
cacheManagerNamesByCacheName.add(cacheName,
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ConfigurationPropertiesReportEndpoint
|
||||
}
|
||||
|
||||
private Map<String, Object> extract(ApplicationContext context, ObjectMapper mapper) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
ConfigurationBeanFactoryMetaData beanFactoryMetaData = getBeanFactoryMetaData(
|
||||
context);
|
||||
Map<String, Object> beans = getConfigurationPropertiesBeans(context,
|
||||
@@ -108,7 +108,7 @@ public class ConfigurationPropertiesReportEndpoint
|
||||
for (Map.Entry<String, Object> entry : beans.entrySet()) {
|
||||
String beanName = entry.getKey();
|
||||
Object bean = entry.getValue();
|
||||
Map<String, Object> root = new HashMap<String, Object>();
|
||||
Map<String, Object> root = new HashMap<>();
|
||||
String prefix = extractPrefix(context, beanFactoryMetaData, beanName, bean);
|
||||
root.put("prefix", prefix);
|
||||
root.put("properties", sanitize(prefix, safeSerialize(mapper, bean, prefix)));
|
||||
@@ -133,7 +133,7 @@ public class ConfigurationPropertiesReportEndpoint
|
||||
private Map<String, Object> getConfigurationPropertiesBeans(
|
||||
ApplicationContext context,
|
||||
ConfigurationBeanFactoryMetaData beanFactoryMetaData) {
|
||||
Map<String, Object> beans = new HashMap<String, Object>();
|
||||
Map<String, Object> beans = new HashMap<>();
|
||||
beans.putAll(context.getBeansWithAnnotation(ConfigurationProperties.class));
|
||||
if (beanFactoryMetaData != null) {
|
||||
beans.putAll(beanFactoryMetaData
|
||||
@@ -154,13 +154,13 @@ public class ConfigurationPropertiesReportEndpoint
|
||||
String prefix) {
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> result = new HashMap<String, Object>(
|
||||
Map<String, Object> result = new HashMap<>(
|
||||
mapper.convertValue(bean, Map.class));
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return new HashMap<String, Object>(Collections.<String, Object>singletonMap(
|
||||
"error", "Cannot serialize '" + prefix + "'"));
|
||||
return new HashMap<>(Collections.<String, Object>singletonMap("error",
|
||||
"Cannot serialize '" + prefix + "'"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public class ConfigurationPropertiesReportEndpoint
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Object> sanitize(String prefix, List<Object> list) {
|
||||
List<Object> sanitized = new ArrayList<Object>();
|
||||
List<Object> sanitized = new ArrayList<>();
|
||||
for (Object item : list) {
|
||||
if (item instanceof Map) {
|
||||
sanitized.add(sanitize(prefix, (Map<String, Object>) item));
|
||||
@@ -317,7 +317,7 @@ public class ConfigurationPropertiesReportEndpoint
|
||||
@Override
|
||||
public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
|
||||
BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
|
||||
List<BeanPropertyWriter> result = new ArrayList<BeanPropertyWriter>();
|
||||
List<BeanPropertyWriter> result = new ArrayList<>();
|
||||
for (BeanPropertyWriter writer : beanProperties) {
|
||||
boolean readable = isReadable(beanDesc, writer);
|
||||
if (readable) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public class DataSourcePublicMetrics implements PublicMetrics {
|
||||
@Autowired
|
||||
private Collection<DataSourcePoolMetadataProvider> providers;
|
||||
|
||||
private final Map<String, DataSourcePoolMetadata> metadataByPrefix = new HashMap<String, DataSourcePoolMetadata>();
|
||||
private final Map<String, DataSourcePoolMetadata> metadataByPrefix = new HashMap<>();
|
||||
|
||||
@PostConstruct
|
||||
public void initialize() {
|
||||
@@ -72,7 +72,7 @@ public class DataSourcePublicMetrics implements PublicMetrics {
|
||||
|
||||
@Override
|
||||
public Collection<Metric<?>> metrics() {
|
||||
Set<Metric<?>> metrics = new LinkedHashSet<Metric<?>>();
|
||||
Set<Metric<?>> metrics = new LinkedHashSet<>();
|
||||
for (Map.Entry<String, DataSourcePoolMetadata> entry : this.metadataByPrefix
|
||||
.entrySet()) {
|
||||
String prefix = entry.getKey();
|
||||
@@ -87,7 +87,7 @@ public class DataSourcePublicMetrics implements PublicMetrics {
|
||||
private <T extends Number> void addMetric(Set<Metric<?>> metrics, String name,
|
||||
T value) {
|
||||
if (value != null) {
|
||||
metrics.add(new Metric<T>(name, value));
|
||||
metrics.add(new Metric<>(name, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,14 +54,14 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> invoke() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("profiles", getEnvironment().getActiveProfiles());
|
||||
for (Entry<String, PropertySource<?>> entry : getPropertySources().entrySet()) {
|
||||
PropertySource<?> source = entry.getValue();
|
||||
String sourceName = entry.getKey();
|
||||
if (source instanceof EnumerablePropertySource) {
|
||||
EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
|
||||
Map<String, Object> properties = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> properties = new LinkedHashMap<>();
|
||||
for (String name : enumerable.getPropertyNames()) {
|
||||
properties.put(name, sanitize(name, enumerable.getProperty(name)));
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||
}
|
||||
|
||||
private Map<String, PropertySource<?>> getPropertySources() {
|
||||
Map<String, PropertySource<?>> map = new LinkedHashMap<String, PropertySource<?>>();
|
||||
Map<String, PropertySource<?>> map = new LinkedHashMap<>();
|
||||
MutablePropertySources sources = null;
|
||||
Environment environment = getEnvironment();
|
||||
if (environment != null && environment instanceof ConfigurableEnvironment) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,9 +56,9 @@ public class FlywayEndpoint extends AbstractEndpoint<List<FlywayReport>> {
|
||||
|
||||
@Override
|
||||
public List<FlywayReport> invoke() {
|
||||
List<FlywayReport> reports = new ArrayList<FlywayReport>();
|
||||
List<FlywayReport> reports = new ArrayList<>();
|
||||
for (Map.Entry<String, Flyway> entry : this.flyways.entrySet()) {
|
||||
List<FlywayMigration> migrations = new ArrayList<FlywayMigration>();
|
||||
List<FlywayMigration> migrations = new ArrayList<>();
|
||||
for (MigrationInfo info : entry.getValue().info().all()) {
|
||||
migrations.add(new FlywayMigration(info));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class LiquibaseEndpoint extends AbstractEndpoint<List<LiquibaseReport>> {
|
||||
|
||||
@Override
|
||||
public List<LiquibaseReport> invoke() {
|
||||
List<LiquibaseReport> reports = new ArrayList<LiquibaseReport>();
|
||||
List<LiquibaseReport> reports = new ArrayList<>();
|
||||
DatabaseFactory factory = DatabaseFactory.getInstance();
|
||||
StandardChangeLogHistoryService service = new StandardChangeLogHistoryService();
|
||||
for (Map.Entry<String, SpringLiquibase> entry : this.liquibases.entrySet()) {
|
||||
|
||||
@@ -59,7 +59,7 @@ public class LoggersEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||
if (configurations == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
result.put("levels", getLevels());
|
||||
result.put("loggers", getLoggers(configurations));
|
||||
return result;
|
||||
@@ -67,13 +67,12 @@ public class LoggersEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||
|
||||
private NavigableSet<LogLevel> getLevels() {
|
||||
Set<LogLevel> levels = this.loggingSystem.getSupportedLogLevels();
|
||||
return new TreeSet<LogLevel>(levels).descendingSet();
|
||||
return new TreeSet<>(levels).descendingSet();
|
||||
}
|
||||
|
||||
private Map<String, LoggerLevels> getLoggers(
|
||||
Collection<LoggerConfiguration> configurations) {
|
||||
Map<String, LoggerLevels> loggers = new LinkedHashMap<String, LoggerLevels>(
|
||||
configurations.size());
|
||||
Map<String, LoggerLevels> loggers = new LinkedHashMap<>(configurations.size());
|
||||
for (LoggerConfiguration configuration : configurations) {
|
||||
loggers.put(configuration.getName(), new LoggerLevels(configuration));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ public class MetricReaderPublicMetrics implements PublicMetrics {
|
||||
|
||||
@Override
|
||||
public Collection<Metric<?>> metrics() {
|
||||
List<Metric<?>> result = new ArrayList<Metric<?>>();
|
||||
List<Metric<?>> result = new ArrayList<>();
|
||||
for (Metric<?> metric : this.metricReader.findAll()) {
|
||||
result.add(metric);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||
public MetricsEndpoint(Collection<PublicMetrics> publicMetrics) {
|
||||
super("metrics");
|
||||
Assert.notNull(publicMetrics, "PublicMetrics must not be null");
|
||||
this.publicMetrics = new ArrayList<PublicMetrics>(publicMetrics);
|
||||
this.publicMetrics = new ArrayList<>(publicMetrics);
|
||||
AnnotationAwareOrderComparator.sort(this.publicMetrics);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ public class MetricsEndpoint extends AbstractEndpoint<Map<String, Object>> {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> invoke() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
List<PublicMetrics> metrics = new ArrayList<PublicMetrics>(this.publicMetrics);
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
List<PublicMetrics> metrics = new ArrayList<>(this.publicMetrics);
|
||||
for (PublicMetrics publicMetric : metrics) {
|
||||
try {
|
||||
for (Metric<?> metric : publicMetric.metrics()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,20 +46,20 @@ public class MetricsEndpointMetricReader implements MetricReader {
|
||||
Metric<Number> metric = null;
|
||||
Object value = this.endpoint.invoke().get(metricName);
|
||||
if (value != null) {
|
||||
metric = new Metric<Number>(metricName, (Number) value);
|
||||
metric = new Metric<>(metricName, (Number) value);
|
||||
}
|
||||
return metric;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Metric<?>> findAll() {
|
||||
List<Metric<?>> metrics = new ArrayList<Metric<?>>();
|
||||
List<Metric<?>> metrics = new ArrayList<>();
|
||||
Map<String, Object> values = this.endpoint.invoke();
|
||||
Date timestamp = new Date();
|
||||
for (Entry<String, Object> entry : values.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
metrics.add(new Metric<Number>(name, (Number) value, timestamp));
|
||||
metrics.add(new Metric<>(name, (Number) value, timestamp));
|
||||
}
|
||||
return metrics;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,7 +77,7 @@ public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object>
|
||||
|
||||
@Override
|
||||
public Map<String, Object> invoke() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
extractHandlerMappings(this.handlerMappings, result);
|
||||
extractHandlerMappings(this.applicationContext, result);
|
||||
extractMethodMappings(this.methodMappings, result);
|
||||
@@ -94,7 +94,7 @@ public class RequestMappingEndpoint extends AbstractEndpoint<Map<String, Object>
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<?, HandlerMethod> methods = bean.getValue().getHandlerMethods();
|
||||
for (Entry<?, HandlerMethod> method : methods.entrySet()) {
|
||||
Map<String, String> map = new LinkedHashMap<String, String>();
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("bean", bean.getKey());
|
||||
map.put("method", method.getValue().toString());
|
||||
result.put(method.getKey().toString(), map);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,7 @@ public class RichGaugeReaderPublicMetrics implements PublicMetrics {
|
||||
|
||||
@Override
|
||||
public Collection<Metric<?>> metrics() {
|
||||
List<Metric<?>> result = new ArrayList<Metric<?>>();
|
||||
List<Metric<?>> result = new ArrayList<>();
|
||||
for (RichGauge richGauge : this.richGaugeReader.findAll()) {
|
||||
result.addAll(convert(richGauge));
|
||||
}
|
||||
@@ -50,15 +50,13 @@ public class RichGaugeReaderPublicMetrics implements PublicMetrics {
|
||||
}
|
||||
|
||||
private List<Metric<?>> convert(RichGauge gauge) {
|
||||
List<Metric<?>> result = new ArrayList<Metric<?>>(6);
|
||||
result.add(
|
||||
new Metric<Double>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
|
||||
result.add(new Metric<Double>(gauge.getName() + RichGauge.VAL, gauge.getValue()));
|
||||
result.add(new Metric<Double>(gauge.getName() + RichGauge.MIN, gauge.getMin()));
|
||||
result.add(new Metric<Double>(gauge.getName() + RichGauge.MAX, gauge.getMax()));
|
||||
result.add(
|
||||
new Metric<Double>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
|
||||
result.add(new Metric<Long>(gauge.getName() + RichGauge.COUNT, gauge.getCount()));
|
||||
List<Metric<?>> result = new ArrayList<>(6);
|
||||
result.add(new Metric<>(gauge.getName() + RichGauge.AVG, gauge.getAverage()));
|
||||
result.add(new Metric<>(gauge.getName() + RichGauge.VAL, gauge.getValue()));
|
||||
result.add(new Metric<>(gauge.getName() + RichGauge.MIN, gauge.getMin()));
|
||||
result.add(new Metric<>(gauge.getName() + RichGauge.MAX, gauge.getMax()));
|
||||
result.add(new Metric<>(gauge.getName() + RichGauge.ALPHA, gauge.getAlpha()));
|
||||
result.add(new Metric<>(gauge.getName() + RichGauge.COUNT, gauge.getCount()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,7 +53,7 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
|
||||
|
||||
@Override
|
||||
public Collection<Metric<?>> metrics() {
|
||||
Collection<Metric<?>> result = new LinkedHashSet<Metric<?>>();
|
||||
Collection<Metric<?>> result = new LinkedHashSet<>();
|
||||
addBasicMetrics(result);
|
||||
addManagementMetrics(result);
|
||||
return result;
|
||||
@@ -69,8 +69,8 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
|
||||
result.add(newMemoryMetric("mem",
|
||||
runtime.totalMemory() + getTotalNonHeapMemoryIfPossible()));
|
||||
result.add(newMemoryMetric("mem.free", runtime.freeMemory()));
|
||||
result.add(new Metric<Integer>("processors", runtime.availableProcessors()));
|
||||
result.add(new Metric<Long>("instance.uptime",
|
||||
result.add(new Metric<>("processors", runtime.availableProcessors()));
|
||||
result.add(new Metric<>("instance.uptime",
|
||||
System.currentTimeMillis() - this.timestamp));
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
|
||||
private void addManagementMetrics(Collection<Metric<?>> result) {
|
||||
try {
|
||||
// Add JVM up time in ms
|
||||
result.add(new Metric<Long>("uptime",
|
||||
result.add(new Metric<>("uptime",
|
||||
ManagementFactory.getRuntimeMXBean().getUptime()));
|
||||
result.add(new Metric<Double>("systemload.average",
|
||||
result.add(new Metric<>("systemload.average",
|
||||
ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage()));
|
||||
addHeapMetrics(result);
|
||||
addNonHeapMetrics(result);
|
||||
@@ -133,7 +133,7 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
|
||||
}
|
||||
|
||||
private Metric<Long> newMemoryMetric(String name, long bytes) {
|
||||
return new Metric<Long>(name, bytes / 1024);
|
||||
return new Metric<>(name, bytes / 1024);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,13 +142,13 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
|
||||
*/
|
||||
protected void addThreadMetrics(Collection<Metric<?>> result) {
|
||||
ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean();
|
||||
result.add(new Metric<Long>("threads.peak",
|
||||
(long) threadMxBean.getPeakThreadCount()));
|
||||
result.add(new Metric<Long>("threads.daemon",
|
||||
result.add(
|
||||
new Metric<>("threads.peak", (long) threadMxBean.getPeakThreadCount()));
|
||||
result.add(new Metric<>("threads.daemon",
|
||||
(long) threadMxBean.getDaemonThreadCount()));
|
||||
result.add(new Metric<Long>("threads.totalStarted",
|
||||
result.add(new Metric<>("threads.totalStarted",
|
||||
threadMxBean.getTotalStartedThreadCount()));
|
||||
result.add(new Metric<Long>("threads", (long) threadMxBean.getThreadCount()));
|
||||
result.add(new Metric<>("threads", (long) threadMxBean.getThreadCount()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,11 +157,11 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
|
||||
*/
|
||||
protected void addClassLoadingMetrics(Collection<Metric<?>> result) {
|
||||
ClassLoadingMXBean classLoadingMxBean = ManagementFactory.getClassLoadingMXBean();
|
||||
result.add(new Metric<Long>("classes",
|
||||
(long) classLoadingMxBean.getLoadedClassCount()));
|
||||
result.add(new Metric<Long>("classes.loaded",
|
||||
result.add(
|
||||
new Metric<>("classes", (long) classLoadingMxBean.getLoadedClassCount()));
|
||||
result.add(new Metric<>("classes.loaded",
|
||||
classLoadingMxBean.getTotalLoadedClassCount()));
|
||||
result.add(new Metric<Long>("classes.unloaded",
|
||||
result.add(new Metric<>("classes.unloaded",
|
||||
classLoadingMxBean.getUnloadedClassCount()));
|
||||
}
|
||||
|
||||
@@ -174,9 +174,9 @@ public class SystemPublicMetrics implements PublicMetrics, Ordered {
|
||||
.getGarbageCollectorMXBeans();
|
||||
for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMxBeans) {
|
||||
String name = beautifyGcName(garbageCollectorMXBean.getName());
|
||||
result.add(new Metric<Long>("gc." + name + ".count",
|
||||
result.add(new Metric<>("gc." + name + ".count",
|
||||
garbageCollectorMXBean.getCollectionCount()));
|
||||
result.add(new Metric<Long>("gc." + name + ".time",
|
||||
result.add(new Metric<>("gc." + name + ".time",
|
||||
garbageCollectorMXBean.getCollectionTime()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,7 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
|
||||
}
|
||||
|
||||
private Manager getManager(EmbeddedWebApplicationContext applicationContext) {
|
||||
EmbeddedWebServer embeddedWebServer = applicationContext
|
||||
.getEmbeddedWebServer();
|
||||
EmbeddedWebServer embeddedWebServer = applicationContext.getEmbeddedWebServer();
|
||||
if (embeddedWebServer instanceof TomcatEmbeddedServletContainer) {
|
||||
return getManager((TomcatEmbeddedServletContainer) embeddedWebServer);
|
||||
}
|
||||
@@ -77,7 +76,7 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
|
||||
}
|
||||
|
||||
private Collection<Metric<?>> metrics(Manager manager) {
|
||||
List<Metric<?>> metrics = new ArrayList<Metric<?>>(2);
|
||||
List<Metric<?>> metrics = new ArrayList<>(2);
|
||||
if (manager instanceof ManagerBase) {
|
||||
addMetric(metrics, "httpsessions.max",
|
||||
((ManagerBase) manager).getMaxActiveSessions());
|
||||
@@ -87,7 +86,7 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
|
||||
}
|
||||
|
||||
private void addMetric(List<Metric<?>> metrics, String name, Integer value) {
|
||||
metrics.add(new Metric<Integer>(name, value));
|
||||
metrics.add(new Metric<>(name, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,7 +81,7 @@ public class EndpointMBeanExporter extends MBeanExporter
|
||||
private final MetadataNamingStrategy defaultNamingStrategy = new MetadataNamingStrategy(
|
||||
this.attributeSource);
|
||||
|
||||
private final Set<Class<?>> registeredEndpoints = new HashSet<Class<?>>();
|
||||
private final Set<Class<?>> registeredEndpoints = new HashSet<>();
|
||||
|
||||
private volatile boolean autoStartup = true;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -91,7 +91,7 @@ public abstract class AbstractEndpointHandlerMapping<E extends MvcEndpoint>
|
||||
*/
|
||||
public AbstractEndpointHandlerMapping(Collection<? extends E> endpoints,
|
||||
CorsConfiguration corsConfiguration) {
|
||||
this.endpoints = new HashSet<E>(endpoints);
|
||||
this.endpoints = new HashSet<>(endpoints);
|
||||
postProcessEndpoints(this.endpoints);
|
||||
this.corsConfiguration = corsConfiguration;
|
||||
// By default the static resource handler mapping is LOWEST_PRECEDENCE - 1
|
||||
@@ -166,7 +166,7 @@ public abstract class AbstractEndpointHandlerMapping<E extends MvcEndpoint>
|
||||
if (defaultPatterns.isEmpty()) {
|
||||
return new String[] { patternPrefix, patternPrefix + ".json" };
|
||||
}
|
||||
List<String> patterns = new ArrayList<String>(defaultPatterns);
|
||||
List<String> patterns = new ArrayList<>(defaultPatterns);
|
||||
for (int i = 0; i < patterns.size(); i++) {
|
||||
patterns.set(i, patternPrefix + patterns.get(i));
|
||||
}
|
||||
@@ -205,7 +205,7 @@ public abstract class AbstractEndpointHandlerMapping<E extends MvcEndpoint>
|
||||
}
|
||||
|
||||
private HandlerExecutionChain addSecurityInterceptor(HandlerExecutionChain chain) {
|
||||
List<HandlerInterceptor> interceptors = new ArrayList<HandlerInterceptor>();
|
||||
List<HandlerInterceptor> interceptors = new ArrayList<>();
|
||||
if (chain.getInterceptors() != null) {
|
||||
interceptors.addAll(Arrays.asList(chain.getInterceptors()));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AuditEventsMvcEndpoint extends AbstractNamedMvcEndpoint {
|
||||
if (!isEnabled()) {
|
||||
return DISABLED_RESPONSE;
|
||||
}
|
||||
Map<Object, Object> result = new LinkedHashMap<Object, Object>();
|
||||
Map<Object, Object> result = new LinkedHashMap<>();
|
||||
result.put("events", this.auditEventRepository.find(principal, after, type));
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class HalBrowserMvcEndpoint extends HalJsonMvcEndpoint
|
||||
throws IOException {
|
||||
byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
|
||||
String content = new String(bytes, DEFAULT_CHARSET);
|
||||
List<String> pathSegments = new ArrayList<String>(ServletUriComponentsBuilder
|
||||
List<String> pathSegments = new ArrayList<>(ServletUriComponentsBuilder
|
||||
.fromRequest(request).build().getPathSegments());
|
||||
pathSegments.remove(pathSegments.size() - 1);
|
||||
String initial = "/"
|
||||
|
||||
@@ -60,7 +60,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
|
||||
|
||||
private final List<String> roles;
|
||||
|
||||
private Map<String, HttpStatus> statusMapping = new HashMap<String, HttpStatus>();
|
||||
private Map<String, HttpStatus> statusMapping = new HashMap<>();
|
||||
|
||||
private RelaxedPropertyResolver securityPropertyResolver;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
|
||||
*/
|
||||
public void setStatusMapping(Map<String, HttpStatus> statusMapping) {
|
||||
Assert.notNull(statusMapping, "StatusMapping must not be null");
|
||||
this.statusMapping = new HashMap<String, HttpStatus>(statusMapping);
|
||||
this.statusMapping = new HashMap<>(statusMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +145,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
|
||||
Health health = getHealth(request, principal);
|
||||
HttpStatus status = getStatus(health);
|
||||
if (status != null) {
|
||||
return new ResponseEntity<Health>(health, status);
|
||||
return new ResponseEntity<>(health, status);
|
||||
}
|
||||
return health;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,7 +38,7 @@ public interface MvcEndpoint {
|
||||
/**
|
||||
* A {@link ResponseEntity} returned for disabled endpoints.
|
||||
*/
|
||||
ResponseEntity<Map<String, String>> DISABLED_RESPONSE = new ResponseEntity<Map<String, String>>(
|
||||
ResponseEntity<Map<String, String>> DISABLED_RESPONSE = new ResponseEntity<>(
|
||||
Collections.singletonMap("message", "This endpoint is disabled"),
|
||||
HttpStatus.NOT_FOUND);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,7 +42,7 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
private final Set<MvcEndpoint> endpoints = new HashSet<MvcEndpoint>();
|
||||
private final Set<MvcEndpoint> endpoints = new HashSet<>();
|
||||
|
||||
private Set<Class<?>> customTypes;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
|
||||
}
|
||||
|
||||
private Set<Class<?>> findEndpointClasses(Collection<MvcEndpoint> existing) {
|
||||
Set<Class<?>> types = new HashSet<Class<?>>();
|
||||
Set<Class<?>> types = new HashSet<>();
|
||||
for (MvcEndpoint endpoint : existing) {
|
||||
Class<?> type = endpoint.getEndpointType();
|
||||
if (type != null) {
|
||||
@@ -99,7 +99,7 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <E extends MvcEndpoint> Set<E> getEndpoints(Class<E> type) {
|
||||
Set<E> result = new HashSet<E>(this.endpoints.size());
|
||||
Set<E> result = new HashSet<>(this.endpoints.size());
|
||||
for (MvcEndpoint candidate : this.endpoints) {
|
||||
if (type.isInstance(candidate)) {
|
||||
result.add((E) candidate);
|
||||
|
||||
@@ -46,7 +46,7 @@ abstract class NamePatternFilter<T> {
|
||||
public Map<String, Object> getResults(String name) {
|
||||
if (!isRegex(name)) {
|
||||
Object value = getValue(this.source, name);
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put(name, value);
|
||||
return result;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ abstract class NamePatternFilter<T> {
|
||||
|
||||
private final Pattern pattern;
|
||||
|
||||
private final Map<String, Object> results = new LinkedHashMap<String, Object>();
|
||||
private final Map<String, Object> results = new LinkedHashMap<>();
|
||||
|
||||
ResultCollectingNameCallback(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ShutdownMvcEndpoint extends EndpointMvcAdapter {
|
||||
@Override
|
||||
public Object invoke() {
|
||||
if (!getDelegate().isEnabled()) {
|
||||
return new ResponseEntity<Map<String, String>>(
|
||||
return new ResponseEntity<>(
|
||||
Collections.singletonMap("message", "This endpoint is disabled"),
|
||||
HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,7 @@ public abstract class AbstractHealthAggregator implements HealthAggregator {
|
||||
|
||||
@Override
|
||||
public final Health aggregate(Map<String, Health> healths) {
|
||||
List<Status> statusCandidates = new ArrayList<Status>();
|
||||
List<Status> statusCandidates = new ArrayList<>();
|
||||
for (Map.Entry<String, Health> entry : healths.entrySet()) {
|
||||
statusCandidates.add(entry.getValue().getStatus());
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public abstract class AbstractHealthAggregator implements HealthAggregator {
|
||||
* @since 1.3.1
|
||||
*/
|
||||
protected Map<String, Object> aggregateDetails(Map<String, Health> healths) {
|
||||
return new LinkedHashMap<String, Object>(healths);
|
||||
return new LinkedHashMap<>(healths);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,7 +53,7 @@ public class CompositeHealthIndicator implements HealthIndicator {
|
||||
Map<String, HealthIndicator> indicators) {
|
||||
Assert.notNull(healthAggregator, "HealthAggregator must not be null");
|
||||
Assert.notNull(indicators, "Indicators must not be null");
|
||||
this.indicators = new LinkedHashMap<String, HealthIndicator>(indicators);
|
||||
this.indicators = new LinkedHashMap<>(indicators);
|
||||
this.healthAggregator = healthAggregator;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class CompositeHealthIndicator implements HealthIndicator {
|
||||
|
||||
@Override
|
||||
public Health health() {
|
||||
Map<String, Health> healths = new LinkedHashMap<String, Health>();
|
||||
Map<String, Health> healths = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, HealthIndicator> entry : this.indicators.entrySet()) {
|
||||
healths.put(entry.getKey(), entry.getValue().health());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,7 +34,7 @@ public class ElasticsearchHealthIndicatorProperties {
|
||||
/**
|
||||
* Comma-separated index names.
|
||||
*/
|
||||
private List<String> indices = new ArrayList<String>();
|
||||
private List<String> indices = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Time, in milliseconds, to wait for a response from the cluster.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -182,7 +182,7 @@ public final class Health {
|
||||
*/
|
||||
public Builder() {
|
||||
this.status = Status.UNKNOWN;
|
||||
this.details = new LinkedHashMap<String, Object>();
|
||||
this.details = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +192,7 @@ public final class Health {
|
||||
public Builder(Status status) {
|
||||
Assert.notNull(status, "Status must not be null");
|
||||
this.status = status;
|
||||
this.details = new LinkedHashMap<String, Object>();
|
||||
this.details = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@ public final class Health {
|
||||
Assert.notNull(status, "Status must not be null");
|
||||
Assert.notNull(details, "Details must not be null");
|
||||
this.status = status;
|
||||
this.details = new LinkedHashMap<String, Object>(details);
|
||||
this.details = new LinkedHashMap<>(details);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,7 +69,7 @@ public class OrderedHealthAggregator extends AbstractHealthAggregator {
|
||||
@Override
|
||||
protected Status aggregateStatus(List<Status> candidates) {
|
||||
// Only sort those status instances that we know about
|
||||
List<Status> filteredCandidates = new ArrayList<Status>();
|
||||
List<Status> filteredCandidates = new ArrayList<>();
|
||||
for (Status candidate : candidates) {
|
||||
if (this.statusOrder.contains(candidate.getCode())) {
|
||||
filteredCandidates.add(candidate);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,7 @@ public final class Info {
|
||||
private final Map<String, Object> details;
|
||||
|
||||
private Info(Builder builder) {
|
||||
LinkedHashMap<String, Object> content = new LinkedHashMap<String, Object>();
|
||||
LinkedHashMap<String, Object> content = new LinkedHashMap<>();
|
||||
content.putAll(builder.content);
|
||||
this.details = Collections.unmodifiableMap(content);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public final class Info {
|
||||
private final Map<String, Object> content;
|
||||
|
||||
public Builder() {
|
||||
this.content = new LinkedHashMap<String, Object>();
|
||||
this.content = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ public class MapInfoContributor implements InfoContributor {
|
||||
private final Map<String, Object> info;
|
||||
|
||||
public MapInfoContributor(Map<String, Object> info) {
|
||||
this.info = new LinkedHashMap<String, Object>(info);
|
||||
this.info = new LinkedHashMap<>(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -91,7 +91,7 @@ public class Metric<T extends Number> {
|
||||
* @return a new {@link Metric} instance
|
||||
*/
|
||||
public Metric<Long> increment(int amount) {
|
||||
return new Metric<Long>(this.getName(),
|
||||
return new Metric<>(this.getName(),
|
||||
Long.valueOf(this.getValue().longValue() + amount));
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class Metric<T extends Number> {
|
||||
* @return a new {@link Metric} instance
|
||||
*/
|
||||
public <S extends Number> Metric<S> set(S value) {
|
||||
return new Metric<S>(this.getName(), value);
|
||||
return new Metric<>(this.getName(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -107,7 +107,7 @@ public class AggregateMetricReader implements MetricReader {
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
Set<String> names = new HashSet<String>();
|
||||
Set<String> names = new HashSet<>();
|
||||
for (Metric<?> metric : this.source.findAll()) {
|
||||
String name = getSourceKey(metric.getName());
|
||||
if (name != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import org.springframework.boot.actuate.metrics.CounterService;
|
||||
*/
|
||||
public class BufferCounterService implements CounterService {
|
||||
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<String, String>();
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<>();
|
||||
|
||||
private final CounterBuffers buffers;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import org.springframework.boot.actuate.metrics.GaugeService;
|
||||
*/
|
||||
public class BufferGaugeService implements GaugeService {
|
||||
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<String, String>();
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<>();
|
||||
|
||||
private final GaugeBuffers buffers;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -72,7 +72,7 @@ public class BufferMetricReader implements MetricReader, PrefixMetricReader {
|
||||
}
|
||||
|
||||
private Iterable<Metric<?>> findAll(Predicate<String> predicate) {
|
||||
final List<Metric<?>> metrics = new ArrayList<Metric<?>>();
|
||||
final List<Metric<?>> metrics = new ArrayList<>();
|
||||
collectMetrics(this.gaugeBuffers, predicate, metrics);
|
||||
collectMetrics(this.counterBuffers, predicate, metrics);
|
||||
return metrics;
|
||||
@@ -92,7 +92,7 @@ public class BufferMetricReader implements MetricReader, PrefixMetricReader {
|
||||
}
|
||||
|
||||
private <T extends Number> Metric<T> asMetric(final String name, Buffer<T> buffer) {
|
||||
return new Metric<T>(name, buffer.getValue(), new Date(buffer.getTimestamp()));
|
||||
return new Metric<>(name, buffer.getValue(), new Date(buffer.getTimestamp()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import java.util.function.Predicate;
|
||||
*/
|
||||
abstract class Buffers<B extends Buffer<?>> {
|
||||
|
||||
private final ConcurrentHashMap<String, B> buffers = new ConcurrentHashMap<String, B>();
|
||||
private final ConcurrentHashMap<String, B> buffers = new ConcurrentHashMap<>();
|
||||
|
||||
public void forEach(final Predicate<String> predicate,
|
||||
final BiConsumer<String, B> consumer) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,9 +59,9 @@ public class DropwizardMetricServices implements CounterService, GaugeService {
|
||||
|
||||
private final ReservoirFactory reservoirFactory;
|
||||
|
||||
private final ConcurrentMap<String, SimpleGauge> gauges = new ConcurrentHashMap<String, SimpleGauge>();
|
||||
private final ConcurrentMap<String, SimpleGauge> gauges = new ConcurrentHashMap<>();
|
||||
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<String, String>();
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Create a new {@link DropwizardMetricServices} instance.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -105,7 +105,7 @@ public abstract class AbstractMetricExporter implements Exporter, Closeable, Flu
|
||||
|
||||
private void exportGroups() {
|
||||
for (String group : groups()) {
|
||||
Collection<Metric<?>> values = new ArrayList<Metric<?>>();
|
||||
Collection<Metric<?>> values = new ArrayList<>();
|
||||
for (Metric<?> metric : next(group)) {
|
||||
Date timestamp = metric.getTimestamp();
|
||||
if (canExportTimestamp(timestamp)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,7 +63,7 @@ public class MetricCopyExporter extends AbstractMetricExporter {
|
||||
|
||||
private final CounterWriter counter;
|
||||
|
||||
private ConcurrentMap<String, Long> counts = new ConcurrentHashMap<String, Long>();
|
||||
private ConcurrentMap<String, Long> counts = new ConcurrentHashMap<>();
|
||||
|
||||
private String[] includes = new String[0];
|
||||
|
||||
@@ -145,7 +145,7 @@ public class MetricCopyExporter extends AbstractMetricExporter {
|
||||
else {
|
||||
this.counts.putIfAbsent(value.getName(), delta);
|
||||
}
|
||||
return new Delta<Long>(value.getName(), delta, value.getTimestamp());
|
||||
return new Delta<>(value.getName(), delta, value.getTimestamp());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MetricExportProperties extends TriggerProperties {
|
||||
/**
|
||||
* Specific trigger properties per MetricWriter bean name.
|
||||
*/
|
||||
private Map<String, SpecificTriggerProperties> triggers = new LinkedHashMap<String, SpecificTriggerProperties>();
|
||||
private Map<String, SpecificTriggerProperties> triggers = new LinkedHashMap<>();
|
||||
|
||||
private Aggregate aggregate = new Aggregate();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,13 +40,13 @@ public class MetricExporters implements SchedulingConfigurer, Closeable {
|
||||
|
||||
private MetricReader reader;
|
||||
|
||||
private Map<String, GaugeWriter> writers = new HashMap<String, GaugeWriter>();
|
||||
private Map<String, GaugeWriter> writers = new HashMap<>();
|
||||
|
||||
private final MetricExportProperties properties;
|
||||
|
||||
private final Map<String, Exporter> exporters = new HashMap<String, Exporter>();
|
||||
private final Map<String, Exporter> exporters = new HashMap<>();
|
||||
|
||||
private final Set<String> closeables = new HashSet<String>();
|
||||
private final Set<String> closeables = new HashSet<>();
|
||||
|
||||
public MetricExporters(MetricExportProperties properties) {
|
||||
this.properties = properties;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,9 +41,9 @@ public class PrefixMetricGroupExporter extends AbstractMetricExporter {
|
||||
|
||||
private final PrefixMetricWriter writer;
|
||||
|
||||
private ConcurrentMap<String, Long> counts = new ConcurrentHashMap<String, Long>();
|
||||
private ConcurrentMap<String, Long> counts = new ConcurrentHashMap<>();
|
||||
|
||||
private Set<String> groups = new HashSet<String>();
|
||||
private Set<String> groups = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Create a new exporter for metrics to a writer based on an empty prefix for the
|
||||
@@ -112,7 +112,7 @@ public class PrefixMetricGroupExporter extends AbstractMetricExporter {
|
||||
else {
|
||||
this.counts.putIfAbsent(value.getName(), delta);
|
||||
}
|
||||
return new Delta<Long>(value.getName(), delta, value.getTimestamp());
|
||||
return new Delta<>(value.getName(), delta, value.getTimestamp());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -71,7 +71,7 @@ public class RichGaugeExporter extends AbstractMetricExporter {
|
||||
@Override
|
||||
protected Iterable<Metric<?>> next(String group) {
|
||||
RichGauge rich = this.reader.findOne(group);
|
||||
Collection<Metric<?>> metrics = new ArrayList<Metric<?>>();
|
||||
Collection<Metric<?>> metrics = new ArrayList<>();
|
||||
metrics.add(new Metric<Number>(group + MIN, rich.getMin()));
|
||||
metrics.add(new Metric<Number>(group + MAX, rich.getMax()));
|
||||
metrics.add(new Metric<Number>(group + COUNT, rich.getCount()));
|
||||
@@ -83,7 +83,7 @@ public class RichGaugeExporter extends AbstractMetricExporter {
|
||||
|
||||
@Override
|
||||
protected Iterable<String> groups() {
|
||||
Collection<String> names = new HashSet<String>();
|
||||
Collection<String> names = new HashSet<>();
|
||||
for (RichGauge rich : this.reader.findAll()) {
|
||||
names.add(rich.getName());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,16 +52,16 @@ public class SpringIntegrationMetricReader implements MetricReader {
|
||||
|
||||
@Override
|
||||
public Iterable<Metric<?>> findAll() {
|
||||
List<Metric<?>> result = new ArrayList<Metric<?>>();
|
||||
List<Metric<?>> result = new ArrayList<>();
|
||||
String[] channelNames = this.configurer.getChannelNames();
|
||||
String[] handlerNames = this.configurer.getHandlerNames();
|
||||
String[] sourceNames = this.configurer.getSourceNames();
|
||||
addChannelMetrics(result, channelNames);
|
||||
addHandlerMetrics(result, handlerNames);
|
||||
addSourceMetrics(result, sourceNames);
|
||||
result.add(new Metric<Integer>("integration.handlerCount", handlerNames.length));
|
||||
result.add(new Metric<Integer>("integration.channelCount", channelNames.length));
|
||||
result.add(new Metric<Integer>("integration.sourceCount", sourceNames.length));
|
||||
result.add(new Metric<>("integration.handlerCount", handlerNames.length));
|
||||
result.add(new Metric<>("integration.channelCount", channelNames.length));
|
||||
result.add(new Metric<>("integration.sourceCount", sourceNames.length));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -75,10 +75,10 @@ public class SpringIntegrationMetricReader implements MetricReader {
|
||||
MessageChannelMetrics metrics) {
|
||||
String prefix = "integration.channel." + name;
|
||||
result.addAll(getStatistics(prefix + ".errorRate", metrics.getErrorRate()));
|
||||
result.add(new Metric<Long>(prefix + ".sendCount", metrics.getSendCountLong()));
|
||||
result.add(new Metric<>(prefix + ".sendCount", metrics.getSendCountLong()));
|
||||
result.addAll(getStatistics(prefix + ".sendRate", metrics.getSendRate()));
|
||||
if (metrics instanceof PollableChannelManagement) {
|
||||
result.add(new Metric<Long>(prefix + ".receiveCount",
|
||||
result.add(new Metric<>(prefix + ".receiveCount",
|
||||
((PollableChannelManagement) metrics).getReceiveCountLong()));
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class SpringIntegrationMetricReader implements MetricReader {
|
||||
String prefix = "integration.handler." + name;
|
||||
result.addAll(getStatistics(prefix + ".duration", metrics.getDuration()));
|
||||
long activeCount = metrics.getActiveCountLong();
|
||||
result.add(new Metric<Long>(prefix + ".activeCount", activeCount));
|
||||
result.add(new Metric<>(prefix + ".activeCount", activeCount));
|
||||
}
|
||||
|
||||
private void addSourceMetrics(List<Metric<?>> result, String[] names) {
|
||||
@@ -106,17 +106,17 @@ public class SpringIntegrationMetricReader implements MetricReader {
|
||||
private void addSourceMetrics(List<Metric<?>> result, String name,
|
||||
MessageSourceMetrics sourceMetrics) {
|
||||
String prefix = "integration.source." + name;
|
||||
result.add(new Metric<Long>(prefix + ".messageCount",
|
||||
result.add(new Metric<>(prefix + ".messageCount",
|
||||
sourceMetrics.getMessageCountLong()));
|
||||
}
|
||||
|
||||
private Collection<? extends Metric<?>> getStatistics(String name, Statistics stats) {
|
||||
List<Metric<?>> metrics = new ArrayList<Metric<?>>();
|
||||
metrics.add(new Metric<Double>(name + ".mean", stats.getMean()));
|
||||
metrics.add(new Metric<Double>(name + ".max", stats.getMax()));
|
||||
metrics.add(new Metric<Double>(name + ".min", stats.getMin()));
|
||||
metrics.add(new Metric<Double>(name + ".stdev", stats.getStandardDeviation()));
|
||||
metrics.add(new Metric<Long>(name + ".count", stats.getCountLong()));
|
||||
List<Metric<?>> metrics = new ArrayList<>();
|
||||
metrics.add(new Metric<>(name + ".mean", stats.getMean()));
|
||||
metrics.add(new Metric<>(name + ".max", stats.getMax()));
|
||||
metrics.add(new Metric<>(name + ".min", stats.getMin()));
|
||||
metrics.add(new Metric<>(name + ".stdev", stats.getStandardDeviation()));
|
||||
metrics.add(new Metric<>(name + ".count", stats.getCountLong()));
|
||||
return metrics;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ public class DefaultMetricNamingStrategy implements ObjectNamingStrategy {
|
||||
throws MalformedObjectNameException {
|
||||
ObjectName objectName = this.namingStrategy.getObjectName(managedBean, beanKey);
|
||||
String domain = objectName.getDomain();
|
||||
Hashtable<String, String> table = new Hashtable<String, String>(
|
||||
Hashtable<String, String> table = new Hashtable<>(
|
||||
objectName.getKeyPropertyList());
|
||||
String name = objectName.getKeyProperty("name");
|
||||
if (name != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public class JmxMetricWriter implements MetricWriter {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(JmxMetricWriter.class);
|
||||
|
||||
private final ConcurrentMap<String, MetricValue> values = new ConcurrentHashMap<String, MetricValue>();
|
||||
private final ConcurrentMap<String, MetricValue> values = new ConcurrentHashMap<>();
|
||||
|
||||
private final MBeanExporter exporter;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class JmxMetricWriter implements MetricWriter {
|
||||
|
||||
@ManagedOperation
|
||||
public void increment(String name, long value) {
|
||||
increment(new Delta<Long>(name, value));
|
||||
increment(new Delta<>(name, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +83,7 @@ public class JmxMetricWriter implements MetricWriter {
|
||||
|
||||
@ManagedOperation
|
||||
public void set(String name, double value) {
|
||||
set(new Metric<Double>(name, value));
|
||||
set(new Metric<>(name, value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,9 +52,9 @@ public class DefaultOpenTsdbNamingStrategy implements OpenTsdbNamingStrategy {
|
||||
* Tags to apply to every metric. Open TSDB requires at least one tag, so a "prefix"
|
||||
* tag is added for you by default.
|
||||
*/
|
||||
private Map<String, String> tags = new LinkedHashMap<String, String>();
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
private Map<String, OpenTsdbName> cache = new HashMap<String, OpenTsdbName>();
|
||||
private Map<String, OpenTsdbName> cache = new HashMap<>();
|
||||
|
||||
public DefaultOpenTsdbNamingStrategy() {
|
||||
this.tags.put(DOMAIN_KEY, "org.springframework.metrics");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,8 +74,7 @@ public class OpenTsdbGaugeWriter implements GaugeWriter {
|
||||
*/
|
||||
private MediaType mediaType = MediaType.APPLICATION_JSON;
|
||||
|
||||
private final List<OpenTsdbData> buffer = new ArrayList<OpenTsdbData>(
|
||||
this.bufferSize);
|
||||
private final List<OpenTsdbData> buffer = new ArrayList<>(this.bufferSize);
|
||||
|
||||
private OpenTsdbNamingStrategy namingStrategy = new DefaultOpenTsdbNamingStrategy();
|
||||
|
||||
@@ -149,7 +148,7 @@ public class OpenTsdbGaugeWriter implements GaugeWriter {
|
||||
headers.setAccept(Arrays.asList(this.mediaType));
|
||||
headers.setContentType(this.mediaType);
|
||||
ResponseEntity<Map> response = this.restTemplate.postForEntity(this.url,
|
||||
new HttpEntity<List<OpenTsdbData>>(snapshot, headers), Map.class);
|
||||
new HttpEntity<>(snapshot, headers), Map.class);
|
||||
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||
logger.warn("Cannot write metrics (discarded " + snapshot.size()
|
||||
+ " values): " + response.getBody());
|
||||
@@ -161,7 +160,7 @@ public class OpenTsdbGaugeWriter implements GaugeWriter {
|
||||
if (this.buffer.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<OpenTsdbData> snapshot = new ArrayList<OpenTsdbData>(this.buffer);
|
||||
List<OpenTsdbData> snapshot = new ArrayList<>(this.buffer);
|
||||
this.buffer.clear();
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ public class OpenTsdbName {
|
||||
|
||||
private String metric;
|
||||
|
||||
private Map<String, String> tags = new LinkedHashMap<String, String>();
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
protected OpenTsdbName() {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.boot.actuate.metrics.Metric;
|
||||
*/
|
||||
public class CompositeMetricReader implements MetricReader {
|
||||
|
||||
private final List<MetricReader> readers = new ArrayList<MetricReader>();
|
||||
private final List<MetricReader> readers = new ArrayList<>();
|
||||
|
||||
public CompositeMetricReader(MetricReader... readers) {
|
||||
Collections.addAll(this.readers, readers);
|
||||
@@ -48,7 +48,7 @@ public class CompositeMetricReader implements MetricReader {
|
||||
|
||||
@Override
|
||||
public Iterable<Metric<?>> findAll() {
|
||||
List<Metric<?>> values = new ArrayList<Metric<?>>((int) count());
|
||||
List<Metric<?>> values = new ArrayList<>((int) count());
|
||||
for (MetricReader delegate : this.readers) {
|
||||
Iterable<Metric<?>> all = delegate.findAll();
|
||||
for (Metric<?> value : all) {
|
||||
|
||||
@@ -57,13 +57,13 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
|
||||
|
||||
private static final Log logger = LogFactory.getLog(MetricRegistryMetricReader.class);
|
||||
|
||||
private static final Map<Class<?>, Set<String>> numberKeys = new ConcurrentHashMap<Class<?>, Set<String>>();
|
||||
private static final Map<Class<?>, Set<String>> numberKeys = new ConcurrentHashMap<>();
|
||||
|
||||
private final Object monitor = new Object();
|
||||
|
||||
private final Map<String, String> names = new ConcurrentHashMap<String, String>();
|
||||
private final Map<String, String> names = new ConcurrentHashMap<>();
|
||||
|
||||
private final MultiValueMap<String, String> reverse = new LinkedMultiValueMap<String, String>();
|
||||
private final MultiValueMap<String, String> reverse = new LinkedMultiValueMap<>();
|
||||
|
||||
private final MetricRegistry registry;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
|
||||
if (metric instanceof Gauge) {
|
||||
Object value = ((Gauge<?>) metric).getValue();
|
||||
if (value instanceof Number) {
|
||||
return new Metric<Number>(metricName, (Number) value);
|
||||
return new Metric<>(metricName, (Number) value);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Ignoring gauge '" + name + "' (" + metric
|
||||
@@ -105,10 +105,10 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
|
||||
value = TimeUnit.MILLISECONDS.convert(value.longValue(),
|
||||
TimeUnit.NANOSECONDS);
|
||||
}
|
||||
return new Metric<Number>(metricName, value);
|
||||
return new Metric<>(metricName, value);
|
||||
}
|
||||
}
|
||||
return new Metric<Number>(metricName, getMetric(metric, metricName));
|
||||
return new Metric<>(metricName, getMetric(metric, metricName));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,7 +116,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
|
||||
return new Iterable<Metric<?>>() {
|
||||
@Override
|
||||
public Iterator<Metric<?>> iterator() {
|
||||
Set<Metric<?>> metrics = new HashSet<Metric<?>>();
|
||||
Set<Metric<?>> metrics = new HashSet<>();
|
||||
for (String name : MetricRegistryMetricReader.this.names.keySet()) {
|
||||
Metric<?> metric = findOne(name);
|
||||
if (metric != null) {
|
||||
@@ -236,7 +236,7 @@ public class MetricRegistryMetricReader implements MetricReader, MetricRegistryL
|
||||
private static Set<String> getNumberKeys(Object metric) {
|
||||
Set<String> result = numberKeys.get(metric.getClass());
|
||||
if (result == null) {
|
||||
result = new HashSet<String>();
|
||||
result = new HashSet<>();
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
for (PropertyDescriptor descriptor : BeanUtils
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,7 +32,7 @@ import org.springframework.boot.actuate.metrics.writer.Delta;
|
||||
*/
|
||||
public class InMemoryMetricRepository implements MetricRepository {
|
||||
|
||||
private final SimpleInMemoryRepository<Metric<?>> metrics = new SimpleInMemoryRepository<Metric<?>>();
|
||||
private final SimpleInMemoryRepository<Metric<?>> metrics = new SimpleInMemoryRepository<>();
|
||||
|
||||
public void setValues(ConcurrentNavigableMap<String, Metric<?>> values) {
|
||||
this.metrics.setValues(values);
|
||||
@@ -48,10 +48,10 @@ public class InMemoryMetricRepository implements MetricRepository {
|
||||
@Override
|
||||
public Metric<?> modify(Metric<?> current) {
|
||||
if (current != null) {
|
||||
return new Metric<Long>(metricName,
|
||||
current.increment(amount).getValue(), timestamp);
|
||||
return new Metric<>(metricName, current.increment(amount).getValue(),
|
||||
timestamp);
|
||||
}
|
||||
return new Metric<Long>(metricName, (long) amount, timestamp);
|
||||
return new Metric<>(metricName, (long) amount, timestamp);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,7 @@ public class InMemoryMultiMetricRepository implements MultiMetricRepository {
|
||||
|
||||
private final InMemoryMetricRepository repository;
|
||||
|
||||
private final Collection<String> groups = new HashSet<String>();
|
||||
private final Collection<String> groups = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Create a new {@link InMemoryMetricRepository} backed by a new
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -124,7 +124,7 @@ public class RedisMetricRepository implements MetricRepository {
|
||||
Set<String> keys = this.zSetOperations.range(0, -1);
|
||||
Iterator<String> keysIt = keys.iterator();
|
||||
|
||||
List<Metric<?>> result = new ArrayList<Metric<?>>(keys.size());
|
||||
List<Metric<?>> result = new ArrayList<>(keys.size());
|
||||
List<String> values = this.redisOperations.opsForValue().multiGet(keys);
|
||||
for (String v : values) {
|
||||
String key = keysIt.next();
|
||||
@@ -149,7 +149,7 @@ public class RedisMetricRepository implements MetricRepository {
|
||||
trackMembership(key);
|
||||
double value = this.zSetOperations.incrementScore(key,
|
||||
delta.getValue().doubleValue());
|
||||
String raw = serialize(new Metric<Double>(name, value, delta.getTimestamp()));
|
||||
String raw = serialize(new Metric<>(name, value, delta.getTimestamp()));
|
||||
this.redisOperations.opsForValue().set(key, raw);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class RedisMetricRepository implements MetricRepository {
|
||||
return null;
|
||||
}
|
||||
Date timestamp = new Date(Long.valueOf(v));
|
||||
return new Metric<Double>(nameFor(redisKey), value, timestamp);
|
||||
return new Metric<>(nameFor(redisKey), value, timestamp);
|
||||
}
|
||||
|
||||
private String serialize(Metric<?> entity) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,7 +76,7 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
|
||||
Set<String> keys = zSetOperations.range(0, -1);
|
||||
Iterator<String> keysIt = keys.iterator();
|
||||
|
||||
List<Metric<?>> result = new ArrayList<Metric<?>>(keys.size());
|
||||
List<Metric<?>> result = new ArrayList<>(keys.size());
|
||||
List<String> values = this.redisOperations.opsForValue().multiGet(keys);
|
||||
for (String v : values) {
|
||||
String key = keysIt.next();
|
||||
@@ -109,14 +109,14 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
|
||||
String key = keyFor(delta.getName());
|
||||
double value = zSetOperations.incrementScore(key, delta.getValue().doubleValue());
|
||||
String raw = serialize(
|
||||
new Metric<Double>(delta.getName(), value, delta.getTimestamp()));
|
||||
new Metric<>(delta.getName(), value, delta.getTimestamp()));
|
||||
this.redisOperations.opsForValue().set(key, raw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> groups() {
|
||||
Set<String> range = this.zSetOperations.range(0, -1);
|
||||
Collection<String> result = new ArrayList<String>();
|
||||
Collection<String> result = new ArrayList<>();
|
||||
for (String key : range) {
|
||||
result.add(key.substring(this.prefix.length()));
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
|
||||
|
||||
private Metric<?> deserialize(String group, String redisKey, String v, Double value) {
|
||||
Date timestamp = new Date(Long.valueOf(v));
|
||||
return new Metric<Double>(nameFor(redisKey), value, timestamp);
|
||||
return new Metric<>(nameFor(redisKey), value, timestamp);
|
||||
}
|
||||
|
||||
private String serialize(Metric<?> entity) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,9 +35,9 @@ final class RedisUtils {
|
||||
|
||||
static <K, V> RedisTemplate<K, V> createRedisTemplate(
|
||||
RedisConnectionFactory connectionFactory, Class<V> valueClass) {
|
||||
RedisTemplate<K, V> redisTemplate = new RedisTemplate<K, V>();
|
||||
RedisTemplate<K, V> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
redisTemplate.setValueSerializer(new GenericToStringSerializer<V>(valueClass));
|
||||
redisTemplate.setValueSerializer(new GenericToStringSerializer<>(valueClass));
|
||||
|
||||
// avoids proxy
|
||||
redisTemplate.setExposeConnection(true);
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.boot.actuate.metrics.writer.MetricWriter;
|
||||
*/
|
||||
public class InMemoryRichGaugeRepository implements RichGaugeRepository {
|
||||
|
||||
private final SimpleInMemoryRepository<RichGauge> repository = new SimpleInMemoryRepository<RichGauge>();
|
||||
private final SimpleInMemoryRepository<RichGauge> repository = new SimpleInMemoryRepository<>();
|
||||
|
||||
@Override
|
||||
public void increment(final Delta<?> delta) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MultiMetricRichGaugeReader implements RichGaugeReader {
|
||||
|
||||
@Override
|
||||
public Iterable<RichGauge> findAll() {
|
||||
List<RichGauge> result = new ArrayList<RichGauge>();
|
||||
List<RichGauge> result = new ArrayList<>();
|
||||
for (String name : this.repository.groups()) {
|
||||
result.add(findOne(name));
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
||||
*/
|
||||
public class SimpleInMemoryRepository<T> {
|
||||
|
||||
private ConcurrentNavigableMap<String, T> values = new ConcurrentSkipListMap<String, T>();
|
||||
private ConcurrentNavigableMap<String, T> values = new ConcurrentSkipListMap<>();
|
||||
|
||||
private final ConcurrentMap<String, Object> locks = new ConcurrentHashMap<String, Object>();
|
||||
private final ConcurrentMap<String, Object> locks = new ConcurrentHashMap<>();
|
||||
|
||||
public T update(String name, Callback<T> callback) {
|
||||
Object lock = getLock(name);
|
||||
@@ -75,7 +75,7 @@ public class SimpleInMemoryRepository<T> {
|
||||
}
|
||||
|
||||
public Iterable<T> findAll() {
|
||||
return new ArrayList<T>(this.values.values());
|
||||
return new ArrayList<>(this.values.values());
|
||||
}
|
||||
|
||||
public Iterable<T> findAllWithPrefix(String prefix) {
|
||||
@@ -85,7 +85,7 @@ public class SimpleInMemoryRepository<T> {
|
||||
if (!prefix.endsWith(".")) {
|
||||
prefix = prefix + ".";
|
||||
}
|
||||
return new ArrayList<T>(
|
||||
return new ArrayList<>(
|
||||
this.values.subMap(prefix, false, prefix + "~", true).values());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.boot.actuate.metrics.Metric;
|
||||
*/
|
||||
public class CompositeMetricWriter implements MetricWriter, Iterable<MetricWriter> {
|
||||
|
||||
private final List<MetricWriter> writers = new ArrayList<MetricWriter>();
|
||||
private final List<MetricWriter> writers = new ArrayList<>();
|
||||
|
||||
public CompositeMetricWriter(MetricWriter... writers) {
|
||||
Collections.addAll(this.writers, writers);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ public class DefaultCounterService implements CounterService {
|
||||
|
||||
private final MetricWriter writer;
|
||||
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<String, String>();
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Create a {@link DefaultCounterService} instance.
|
||||
@@ -41,12 +41,12 @@ public class DefaultCounterService implements CounterService {
|
||||
|
||||
@Override
|
||||
public void increment(String metricName) {
|
||||
this.writer.increment(new Delta<Long>(wrap(metricName), 1L));
|
||||
this.writer.increment(new Delta<>(wrap(metricName), 1L));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decrement(String metricName) {
|
||||
this.writer.increment(new Delta<Long>(wrap(metricName), -1L));
|
||||
this.writer.increment(new Delta<>(wrap(metricName), -1L));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,7 @@ public class DefaultGaugeService implements GaugeService {
|
||||
|
||||
private final MetricWriter writer;
|
||||
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<String, String>();
|
||||
private final ConcurrentHashMap<String, String> names = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Create a {@link DefaultGaugeService} instance.
|
||||
@@ -42,7 +42,7 @@ public class DefaultGaugeService implements GaugeService {
|
||||
|
||||
@Override
|
||||
public void submit(String metricName, double value) {
|
||||
this.writer.set(new Metric<Double>(wrap(metricName), value));
|
||||
this.writer.set(new Metric<>(wrap(metricName), value));
|
||||
}
|
||||
|
||||
private String wrap(String metricName) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,7 +74,7 @@ public class AuthenticationAuditListener extends AbstractAuthenticationAuditList
|
||||
}
|
||||
|
||||
private void onAuthenticationFailureEvent(AbstractAuthenticationFailureEvent event) {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("type", event.getException().getClass().getName());
|
||||
data.put("message", event.getException().getMessage());
|
||||
if (event.getAuthentication().getDetails() != null) {
|
||||
@@ -85,7 +85,7 @@ public class AuthenticationAuditListener extends AbstractAuthenticationAuditList
|
||||
}
|
||||
|
||||
private void onAuthenticationSuccessEvent(AuthenticationSuccessEvent event) {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
if (event.getAuthentication().getDetails() != null) {
|
||||
data.put("details", event.getAuthentication().getDetails());
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class AuthenticationAuditListener extends AbstractAuthenticationAuditList
|
||||
AbstractAuthenticationEvent input) {
|
||||
if (listener != null) {
|
||||
AuthenticationSwitchUserEvent event = (AuthenticationSwitchUserEvent) input;
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
if (event.getAuthentication().getDetails() != null) {
|
||||
data.put("details", event.getAuthentication().getDetails());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public class AuthorizationAuditListener extends AbstractAuthorizationAuditListen
|
||||
|
||||
private void onAuthenticationCredentialsNotFoundEvent(
|
||||
AuthenticationCredentialsNotFoundEvent event) {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("type", event.getCredentialsNotFoundException().getClass().getName());
|
||||
data.put("message", event.getCredentialsNotFoundException().getMessage());
|
||||
publish(new AuditEvent("<unknown>",
|
||||
@@ -58,7 +58,7 @@ public class AuthorizationAuditListener extends AbstractAuthorizationAuditListen
|
||||
}
|
||||
|
||||
private void onAuthorizationFailureEvent(AuthorizationFailureEvent event) {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("type", event.getAccessDeniedException().getClass().getName());
|
||||
data.put("message", event.getAccessDeniedException().getMessage());
|
||||
if (event.getAuthentication().getDetails() != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,7 @@ public class InMemoryTraceRepository implements TraceRepository {
|
||||
|
||||
private boolean reverse = true;
|
||||
|
||||
private final List<Trace> traces = new LinkedList<Trace>();
|
||||
private final List<Trace> traces = new LinkedList<>();
|
||||
|
||||
/**
|
||||
* Flag to say that the repository lists traces in reverse order.
|
||||
@@ -60,7 +60,7 @@ public class InMemoryTraceRepository implements TraceRepository {
|
||||
@Override
|
||||
public List<Trace> findAll() {
|
||||
synchronized (this.traces) {
|
||||
return Collections.unmodifiableList(new ArrayList<Trace>(this.traces));
|
||||
return Collections.unmodifiableList(new ArrayList<>(this.traces));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TraceProperties {
|
||||
private static final Set<Include> DEFAULT_INCLUDES;
|
||||
|
||||
static {
|
||||
Set<Include> defaultIncludes = new LinkedHashSet<Include>();
|
||||
Set<Include> defaultIncludes = new LinkedHashSet<>();
|
||||
defaultIncludes.add(Include.REQUEST_HEADERS);
|
||||
defaultIncludes.add(Include.RESPONSE_HEADERS);
|
||||
defaultIncludes.add(Include.COOKIES);
|
||||
@@ -50,7 +50,7 @@ public class TraceProperties {
|
||||
* Items to be included in the trace. Defaults to request/response headers (including
|
||||
* cookies) and errors.
|
||||
*/
|
||||
private Set<Include> include = new HashSet<Include>(DEFAULT_INCLUDES);
|
||||
private Set<Include> include = new HashSet<>(DEFAULT_INCLUDES);
|
||||
|
||||
public Set<Include> getInclude() {
|
||||
return this.include;
|
||||
|
||||
@@ -120,8 +120,8 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
|
||||
Throwable exception = (Throwable) request
|
||||
.getAttribute("javax.servlet.error.exception");
|
||||
Principal userPrincipal = request.getUserPrincipal();
|
||||
Map<String, Object> trace = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> headers = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> trace = new LinkedHashMap<>();
|
||||
Map<String, Object> headers = new LinkedHashMap<>();
|
||||
trace.put("method", request.getMethod());
|
||||
trace.put("path", request.getRequestURI());
|
||||
trace.put("headers", headers);
|
||||
@@ -152,7 +152,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
|
||||
}
|
||||
|
||||
private Map<String, Object> getRequestHeaders(HttpServletRequest request) {
|
||||
Map<String, Object> headers = new LinkedHashMap<String, Object>();
|
||||
Map<String, Object> headers = new LinkedHashMap<>();
|
||||
Set<String> excludedHeaders = getExcludeHeaders();
|
||||
Enumeration<String> names = request.getHeaderNames();
|
||||
while (names.hasMoreElements()) {
|
||||
@@ -166,7 +166,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
|
||||
}
|
||||
|
||||
private Set<String> getExcludeHeaders() {
|
||||
Set<String> excludedHeaders = new HashSet<String>();
|
||||
Set<String> excludedHeaders = new HashSet<>();
|
||||
if (!isIncluded(Include.COOKIES)) {
|
||||
excludedHeaders.add("cookie");
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
|
||||
}
|
||||
|
||||
private Map<String, String> getResponseHeaders(HttpServletResponse response) {
|
||||
Map<String, String> headers = new LinkedHashMap<String, String>();
|
||||
Map<String, String> headers = new LinkedHashMap<>();
|
||||
for (String header : response.getHeaderNames()) {
|
||||
String value = response.getHeader(header);
|
||||
headers.put(header, value);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -102,7 +102,7 @@ public class InMemoryAuditEventRepositoryTests {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(2000, 1, 1, 0, 0, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
InMemoryAuditEventRepository repository = new InMemoryAuditEventRepository();
|
||||
repository.add(new AuditEvent(calendar.getTime(), "dave", "a", data));
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -217,7 +217,7 @@ public class CacheStatisticsAutoConfigurationTests {
|
||||
javax.cache.CacheManager cacheManager = Caching
|
||||
.getCachingProvider(HazelcastCachingProvider.class.getName())
|
||||
.getCacheManager();
|
||||
MutableConfiguration<Object, Object> config = new MutableConfiguration<Object, Object>();
|
||||
MutableConfiguration<Object, Object> config = new MutableConfiguration<>();
|
||||
config.setStatisticsEnabled(true);
|
||||
cacheManager.createCache("books", config);
|
||||
cacheManager.createCache("speakers", config);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -278,7 +278,7 @@ public class EndpointAutoConfigurationTests {
|
||||
return new PublicMetrics() {
|
||||
@Override
|
||||
public Collection<Metric<?>> metrics() {
|
||||
Metric<Integer> metric = new Metric<Integer>("foo", 1);
|
||||
Metric<Integer> metric = new Metric<>("foo", 1);
|
||||
return Collections.<Metric<?>>singleton(metric);
|
||||
}
|
||||
};
|
||||
@@ -310,7 +310,7 @@ public class EndpointAutoConfigurationTests {
|
||||
|
||||
private static class GitFullInfoContributor implements InfoContributor {
|
||||
|
||||
private Map<String, Object> content = new LinkedHashMap<String, Object>();
|
||||
private Map<String, Object> content = new LinkedHashMap<>();
|
||||
|
||||
GitFullInfoContributor(Resource location) throws BindException, IOException {
|
||||
if (location.exists()) {
|
||||
|
||||
@@ -117,7 +117,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
|
||||
private final AnnotationConfigEmbeddedWebApplicationContext applicationContext = new AnnotationConfigEmbeddedWebApplicationContext();
|
||||
|
||||
private static ThreadLocal<Ports> ports = new ThreadLocal<Ports>();
|
||||
private static ThreadLocal<Ports> ports = new ThreadLocal<>();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
@@ -66,5 +66,4 @@ public class ManagementServerPropertiesNoSecurityTests {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -116,8 +116,7 @@ public class ManagementWebSecurityAutoConfigurationTests {
|
||||
this.context.register(WebConfiguration.class);
|
||||
this.context.refresh();
|
||||
UserDetails user = getUser();
|
||||
ArrayList<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(
|
||||
user.getAuthorities());
|
||||
ArrayList<GrantedAuthority> authorities = new ArrayList<>(user.getAuthorities());
|
||||
assertThat(authorities).containsAll(AuthorityUtils
|
||||
.commaSeparatedStringToAuthorityList("ROLE_USER,ROLE_ACTUATOR"));
|
||||
}
|
||||
|
||||
@@ -505,14 +505,14 @@ public class MetricFilterAutoConfigurationTests {
|
||||
|
||||
@RequestMapping("create")
|
||||
public DeferredResult<ResponseEntity<String>> create() {
|
||||
final DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>();
|
||||
final DeferredResult<ResponseEntity<String>> result = new DeferredResult<>();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
MetricFilterTestController.this.latch.await();
|
||||
result.setResult(
|
||||
new ResponseEntity<String>("Done", HttpStatus.CREATED));
|
||||
new ResponseEntity<>("Done", HttpStatus.CREATED));
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
}
|
||||
@@ -523,7 +523,7 @@ public class MetricFilterAutoConfigurationTests {
|
||||
|
||||
@RequestMapping("createFailure")
|
||||
public DeferredResult<ResponseEntity<String>> createFailure() {
|
||||
final DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>();
|
||||
final DeferredResult<ResponseEntity<String>> result = new DeferredResult<>();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -142,9 +142,8 @@ public class MvcEndpointPathConfigurationTests {
|
||||
|
||||
@Configuration
|
||||
@ImportAutoConfiguration({ EndpointAutoConfiguration.class,
|
||||
HttpMessageConvertersAutoConfiguration.class,
|
||||
AuditAutoConfiguration.class, EndpointWebMvcAutoConfiguration.class,
|
||||
JolokiaAutoConfiguration.class })
|
||||
HttpMessageConvertersAutoConfiguration.class, AuditAutoConfiguration.class,
|
||||
EndpointWebMvcAutoConfiguration.class, JolokiaAutoConfiguration.class })
|
||||
|
||||
protected static class TestConfiguration {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -110,12 +110,12 @@ public class PublicMetricsAutoConfigurationTests {
|
||||
Collection<Metric<?>> metrics = publicMetrics.metrics();
|
||||
assertThat(metrics).isNotNull();
|
||||
assertThat(6).isEqualTo(metrics.size());
|
||||
assertHasMetric(metrics, new Metric<Double>("bar.val", 3.7d));
|
||||
assertHasMetric(metrics, new Metric<Double>("bar.avg", 3.7d));
|
||||
assertHasMetric(metrics, new Metric<Double>("bar.min", 3.7d));
|
||||
assertHasMetric(metrics, new Metric<Double>("bar.max", 3.7d));
|
||||
assertHasMetric(metrics, new Metric<Double>("bar.alpha", -1.d));
|
||||
assertHasMetric(metrics, new Metric<Long>("bar.count", 1L));
|
||||
assertHasMetric(metrics, new Metric<>("bar.val", 3.7d));
|
||||
assertHasMetric(metrics, new Metric<>("bar.avg", 3.7d));
|
||||
assertHasMetric(metrics, new Metric<>("bar.min", 3.7d));
|
||||
assertHasMetric(metrics, new Metric<>("bar.max", 3.7d));
|
||||
assertHasMetric(metrics, new Metric<>("bar.alpha", -1.d));
|
||||
assertHasMetric(metrics, new Metric<>("bar.count", 1L));
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class PublicMetricsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
private void assertMetrics(Collection<Metric<?>> metrics, String... keys) {
|
||||
Map<String, Number> content = new HashMap<String, Number>();
|
||||
Map<String, Number> content = new HashMap<>();
|
||||
for (Metric<?> metric : metrics) {
|
||||
content.put(metric.getName(), metric.getValue());
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user