Merge pull request #15695 from izeye

* pr/15695:
  Polish contribution
  Polish
This commit is contained in:
Stephane Nicoll 2019-01-14 08:11:39 -05:00
commit 0fa3844480
10 changed files with 35 additions and 44 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,15 +46,16 @@ class RestTemplateMetricsConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(RestTemplateExchangeTagsProvider.class) @ConditionalOnMissingBean(RestTemplateExchangeTagsProvider.class)
public DefaultRestTemplateExchangeTagsProvider restTemplateTagConfigurer() { public DefaultRestTemplateExchangeTagsProvider restTemplateExchangeTagsProvider() {
return new DefaultRestTemplateExchangeTagsProvider(); return new DefaultRestTemplateExchangeTagsProvider();
} }
@Bean @Bean
public MetricsRestTemplateCustomizer metricsRestTemplateCustomizer( public MetricsRestTemplateCustomizer metricsRestTemplateCustomizer(
MeterRegistry meterRegistry, MeterRegistry meterRegistry,
RestTemplateExchangeTagsProvider restTemplateTagConfigurer) { RestTemplateExchangeTagsProvider restTemplateExchangeTagsProvider) {
return new MetricsRestTemplateCustomizer(meterRegistry, restTemplateTagConfigurer, return new MetricsRestTemplateCustomizer(meterRegistry,
restTemplateExchangeTagsProvider,
this.properties.getWeb().getClient().getRequestsMetricName()); this.properties.getWeb().getClient().getRequestsMetricName());
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -80,8 +80,7 @@ public class RestTemplateMetricsConfigurationTests {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("http.client.requests").meters()).hasSize(2); assertThat(registry.get("http.client.requests").meters()).hasSize(2);
assertThat(this.output.toString()).contains( assertThat(this.output.toString()).contains(
"Reached the maximum number of URI tags for 'http.client.requests'."); "Reached the maximum number of URI tags for 'http.client.requests'.")
assertThat(this.output.toString())
.contains("Are you using 'uriVariables'?"); .contains("Are you using 'uriVariables'?");
}); });
} }
@ -94,8 +93,7 @@ public class RestTemplateMetricsConfigurationTests {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("http.client.requests").meters()).hasSize(3); assertThat(registry.get("http.client.requests").meters()).hasSize(3);
assertThat(this.output.toString()).doesNotContain( assertThat(this.output.toString()).doesNotContain(
"Reached the maximum number of URI tags for 'http.client.requests'."); "Reached the maximum number of URI tags for 'http.client.requests'.")
assertThat(this.output.toString())
.doesNotContain("Are you using 'uriVariables'?"); .doesNotContain("Are you using 'uriVariables'?");
}); });
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -83,8 +83,7 @@ public class WebClientMetricsConfigurationTests {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("http.client.requests").meters()).hasSize(2); assertThat(registry.get("http.client.requests").meters()).hasSize(2);
assertThat(this.output.toString()).contains( assertThat(this.output.toString()).contains(
"Reached the maximum number of URI tags for 'http.client.requests'."); "Reached the maximum number of URI tags for 'http.client.requests'.")
assertThat(this.output.toString())
.contains("Are you using 'uriVariables'?"); .contains("Are you using 'uriVariables'?");
}); });
} }
@ -97,8 +96,7 @@ public class WebClientMetricsConfigurationTests {
MeterRegistry registry = getInitializedMeterRegistry(context); MeterRegistry registry = getInitializedMeterRegistry(context);
assertThat(registry.get("http.client.requests").meters()).hasSize(3); assertThat(registry.get("http.client.requests").meters()).hasSize(3);
assertThat(this.output.toString()).doesNotContain( assertThat(this.output.toString()).doesNotContain(
"Reached the maximum number of URI tags for 'http.client.requests'."); "Reached the maximum number of URI tags for 'http.client.requests'.")
assertThat(this.output.toString())
.doesNotContain("Are you using 'uriVariables'?"); .doesNotContain("Are you using 'uriVariables'?");
}); });
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ public final class EndpointId {
private static final Log logger = LogFactory.getLog(EndpointId.class); private static final Log logger = LogFactory.getLog(EndpointId.class);
private static Set<String> loggedWarnings = new HashSet<>(); private static final Set<String> loggedWarnings = new HashSet<>();
private static final Pattern VALID_PATTERN = Pattern.compile("[a-zA-Z0-9\\.\\-]+"); private static final Pattern VALID_PATTERN = Pattern.compile("[a-zA-Z0-9\\.\\-]+");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -138,8 +138,8 @@ public class ElasticsearchJestHealthIndicatorTests {
status); status);
} }
else { else {
json = "{\n" + " \"error\": \"Server Error\",\n" + " \"status\": " json = "{\n" + " \"error\": \"Server Error\",\n" + " \"status\": \""
+ responseCode + "\n" + "}"; + status + "\"\n" + "}";
} }
searchResult.setJsonString(json); searchResult.setJsonString(json);
searchResult.setJsonObject(new JsonParser().parse(json).getAsJsonObject()); searchResult.setJsonObject(new JsonParser().parse(json).getAsJsonObject());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -72,7 +72,7 @@ public class HttpMessageConverters implements Iterable<HttpMessageConverter<?>>
* converters. * converters.
* @param additionalConverters additional converters to be added. Items are added just * @param additionalConverters additional converters to be added. Items are added just
* before any default converter of the same type (or at the front of the list if no * before any default converter of the same type (or at the front of the list if no
* default converter is found) The {@link #postProcessConverters(List)} method can be * default converter is found). The {@link #postProcessConverters(List)} method can be
* used for further converter manipulation. * used for further converter manipulation.
*/ */
public HttpMessageConverters(HttpMessageConverter<?>... additionalConverters) { public HttpMessageConverters(HttpMessageConverter<?>... additionalConverters) {
@ -84,7 +84,7 @@ public class HttpMessageConverters implements Iterable<HttpMessageConverter<?>>
* converters. * converters.
* @param additionalConverters additional converters to be added. Items are added just * @param additionalConverters additional converters to be added. Items are added just
* before any default converter of the same type (or at the front of the list if no * before any default converter of the same type (or at the front of the list if no
* default converter is found) The {@link #postProcessConverters(List)} method can be * default converter is found). The {@link #postProcessConverters(List)} method can be
* used for further converter manipulation. * used for further converter manipulation.
*/ */
public HttpMessageConverters( public HttpMessageConverters(
@ -97,7 +97,7 @@ public class HttpMessageConverters implements Iterable<HttpMessageConverter<?>>
* @param addDefaultConverters if default converters should be added * @param addDefaultConverters if default converters should be added
* @param converters converters to be added. Items are added just before any default * @param converters converters to be added. Items are added just before any default
* converter of the same type (or at the front of the list if no default converter is * converter of the same type (or at the front of the list if no default converter is
* found) The {@link #postProcessConverters(List)} method can be used for further * found). The {@link #postProcessConverters(List)} method can be used for further
* converter manipulation. * converter manipulation.
*/ */
public HttpMessageConverters(boolean addDefaultConverters, public HttpMessageConverters(boolean addDefaultConverters,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,8 +46,7 @@ public class LdapAutoConfigurationTests {
public void contextSourceWithDefaultUrl() { public void contextSourceWithDefaultUrl() {
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
LdapContextSource contextSource = context.getBean(LdapContextSource.class); LdapContextSource contextSource = context.getBean(LdapContextSource.class);
String[] urls = getUrls(contextSource); assertThat(contextSource.getUrls()).containsExactly("ldap://localhost:389");
assertThat(urls).containsExactly("ldap://localhost:389");
assertThat(contextSource.isAnonymousReadOnly()).isFalse(); assertThat(contextSource.isAnonymousReadOnly()).isFalse();
}); });
} }
@ -58,8 +57,8 @@ public class LdapAutoConfigurationTests {
.run((context) -> { .run((context) -> {
LdapContextSource contextSource = context LdapContextSource contextSource = context
.getBean(LdapContextSource.class); .getBean(LdapContextSource.class);
String[] urls = getUrls(contextSource); assertThat(contextSource.getUrls())
assertThat(urls).containsExactly("ldap://localhost:123"); .containsExactly("ldap://localhost:123");
}); });
} }
@ -72,9 +71,8 @@ public class LdapAutoConfigurationTests {
LdapContextSource contextSource = context LdapContextSource contextSource = context
.getBean(LdapContextSource.class); .getBean(LdapContextSource.class);
LdapProperties ldapProperties = context.getBean(LdapProperties.class); LdapProperties ldapProperties = context.getBean(LdapProperties.class);
String[] urls = getUrls(contextSource); assertThat(contextSource.getUrls()).containsExactly(
assertThat(urls).containsExactly("ldap://localhost:123", "ldap://localhost:123", "ldap://mycompany:123");
"ldap://mycompany:123");
assertThat(ldapProperties.getUrls()).hasSize(2); assertThat(ldapProperties.getUrls()).hasSize(2);
}); });
} }
@ -112,16 +110,12 @@ public class LdapAutoConfigurationTests {
.run((context) -> { .run((context) -> {
LdapContextSource contextSource = context LdapContextSource contextSource = context
.getBean(LdapContextSource.class); .getBean(LdapContextSource.class);
String[] urls = getUrls(contextSource); assertThat(contextSource.getUrls())
assertThat(urls).containsExactly("ldap://localhost:389"); .containsExactly("ldap://localhost:389");
assertThat(contextSource.isAnonymousReadOnly()).isFalse(); assertThat(contextSource.isAnonymousReadOnly()).isFalse();
}); });
} }
private String[] getUrls(LdapContextSource contextSource) {
return contextSource.getUrls();
}
@Configuration @Configuration
static class PooledContextSourceConfig { static class PooledContextSourceConfig {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -97,7 +97,7 @@ class SpringBootTestRandomPortEnvironmentPostProcessor
return environment.getConversionService().convert(value, Integer.class); return environment.getConversionService().convert(value, Integer.class);
} }
catch (ConversionFailedException ex) { catch (ConversionFailedException ex) {
if (ClassUtils.isAssignable(value.getClass(), String.class)) { if (value instanceof String) {
return getResolvedValueIfPossible(environment, (String) value); return getResolvedValueIfPossible(environment, (String) value);
} }
throw ex; throw ex;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -63,7 +63,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
.invoke(runtimeVersion); .invoke(runtimeVersion);
} }
catch (Throwable ex) { catch (Throwable ex) {
version = 8; version = BASE_VERSION;
} }
RUNTIME_VERSION = version; RUNTIME_VERSION = version;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -77,8 +77,8 @@ public class DataSourceUnwrapperTests {
@Test @Test
public void unwrapWithSeveralLevelOfWrapping() { public void unwrapWithSeveralLevelOfWrapping() {
DataSource dataSource = new HikariDataSource(); DataSource dataSource = new HikariDataSource();
DataSource actual = wrapInProxy(wrapInDelegate( DataSource actual = wrapInProxy(
wrapInDelegate((wrapInProxy(wrapInDelegate(dataSource)))))); wrapInDelegate(wrapInDelegate(wrapInProxy(wrapInDelegate(dataSource)))));
assertThat(DataSourceUnwrapper.unwrap(actual, HikariDataSource.class)) assertThat(DataSourceUnwrapper.unwrap(actual, HikariDataSource.class))
.isSameAs(dataSource); .isSameAs(dataSource);
} }