mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-24 18:29:03 +00:00
Polish
This commit is contained in:
+3
-3
@@ -88,11 +88,11 @@ public class MetricsAutoConfiguration {
|
||||
MetricsProperties metricsProperties,
|
||||
ObjectProvider<Collection<MetricsExporter>> exporters,
|
||||
ObjectProvider<Collection<MeterRegistryConfigurer>> configurers) {
|
||||
CompositeMeterRegistry composite = metricsProperties.isUseGlobalRegistry() ?
|
||||
Metrics.globalRegistry : new CompositeMeterRegistry();
|
||||
CompositeMeterRegistry composite = metricsProperties.isUseGlobalRegistry()
|
||||
? Metrics.globalRegistry : new CompositeMeterRegistry();
|
||||
configurers.getIfAvailable(Collections::emptyList)
|
||||
.forEach((configurer) -> configurer.configureRegistry(composite));
|
||||
exporters.getIfAvailable(Collections::emptyList).forEach(exporter -> {
|
||||
exporters.getIfAvailable(Collections::emptyList).forEach((exporter) -> {
|
||||
MeterRegistry childRegistry = exporter.registry();
|
||||
if (composite == childRegistry) {
|
||||
throw new IllegalStateException(
|
||||
|
||||
-3
@@ -55,9 +55,6 @@ public class WebMvcMetricsFilterAutoTimedTests {
|
||||
@Autowired
|
||||
private MeterRegistry registry;
|
||||
|
||||
@Autowired
|
||||
private MockClock clock;
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
|
||||
-3
@@ -65,9 +65,6 @@ public class WebMvcMetricsIntegrationTests {
|
||||
@Autowired
|
||||
private SimpleMeterRegistry registry;
|
||||
|
||||
@Autowired
|
||||
private MockClock clock;
|
||||
|
||||
private MockMvc mvc;
|
||||
|
||||
@Autowired
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class GsonAutoConfiguration {
|
||||
@ConditionalOnMissingBean(GsonBuilder.class)
|
||||
public GsonBuilder gsonBuilder(List<GsonBuilderCustomizer> customizers) {
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
customizers.forEach(c -> c.customize(builder));
|
||||
customizers.forEach((c) -> c.customize(builder));
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
||||
+28
-27
@@ -51,7 +51,7 @@ public class GsonAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void gsonRegistration() {
|
||||
this.contextRunner.run(context -> {
|
||||
this.contextRunner.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.toJson(new DataObject())).isEqualTo("{\"data\":1}");
|
||||
});
|
||||
@@ -61,7 +61,7 @@ public class GsonAutoConfigurationTests {
|
||||
public void generateNonExecutableJson() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.gson.generate-non-executable-json:true")
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.toJson(new DataObject()))
|
||||
.isNotEqualTo("{\"data\":1}");
|
||||
@@ -74,7 +74,7 @@ public class GsonAutoConfigurationTests {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.gson.exclude-fields-without-expose-annotation:true")
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.toJson(new DataObject())).isEqualTo("{}");
|
||||
});
|
||||
@@ -83,7 +83,7 @@ public class GsonAutoConfigurationTests {
|
||||
@Test
|
||||
public void serializeNulls() {
|
||||
this.contextRunner.withPropertyValues("spring.gson.serialize-nulls:true")
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.serializeNulls()).isTrue();
|
||||
});
|
||||
@@ -94,7 +94,7 @@ public class GsonAutoConfigurationTests {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.gson.enable-complex-map-key-serialization:true")
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
Map<DataObject, String> original = new LinkedHashMap<>();
|
||||
original.put(new DataObject(), "a");
|
||||
@@ -104,7 +104,7 @@ public class GsonAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void notDisableInnerClassSerialization() {
|
||||
this.contextRunner.run(context -> {
|
||||
this.contextRunner.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
WrapperObject wrapperObject = new WrapperObject();
|
||||
assertThat(gson.toJson(wrapperObject.new NestedObject()))
|
||||
@@ -116,7 +116,7 @@ public class GsonAutoConfigurationTests {
|
||||
public void disableInnerClassSerialization() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.gson.disable-inner-class-serialization:true")
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
WrapperObject wrapperObject = new WrapperObject();
|
||||
assertThat(gson.toJson(wrapperObject.new NestedObject()))
|
||||
@@ -128,7 +128,7 @@ public class GsonAutoConfigurationTests {
|
||||
public void withLongSerializationPolicy() {
|
||||
this.contextRunner.withPropertyValues(
|
||||
"spring.gson.long-serialization-policy:" + LongSerializationPolicy.STRING)
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.toJson(new DataObject()))
|
||||
.isEqualTo("{\"data\":\"1\"}");
|
||||
@@ -141,7 +141,7 @@ public class GsonAutoConfigurationTests {
|
||||
this.contextRunner
|
||||
.withPropertyValues(
|
||||
"spring.gson.field-naming-policy:" + fieldNamingPolicy)
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.fieldNamingStrategy()).isEqualTo(fieldNamingPolicy);
|
||||
});
|
||||
@@ -150,7 +150,7 @@ public class GsonAutoConfigurationTests {
|
||||
@Test
|
||||
public void additionalGsonBuilderCustomization() {
|
||||
this.contextRunner.withUserConfiguration(GsonBuilderCustomizerConfig.class)
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.toJson(new DataObject())).isEqualTo("{}");
|
||||
});
|
||||
@@ -159,7 +159,7 @@ public class GsonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customGsonBuilder() {
|
||||
this.contextRunner.withUserConfiguration(GsonBuilderConfig.class)
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.toJson(new DataObject()))
|
||||
.isEqualTo("{\"data\":1,\"owner\":null}");
|
||||
@@ -169,7 +169,7 @@ public class GsonAutoConfigurationTests {
|
||||
@Test
|
||||
public void withPrettyPrinting() {
|
||||
this.contextRunner.withPropertyValues("spring.gson.pretty-printing:true")
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.toJson(new DataObject()))
|
||||
.isEqualTo("{\n \"data\": 1\n}");
|
||||
@@ -178,7 +178,7 @@ public class GsonAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void withoutLenient() {
|
||||
this.contextRunner.run(context -> {
|
||||
this.contextRunner.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
/*
|
||||
* It seems that lenient setting not work in version 2.8.2. We get access to
|
||||
@@ -194,23 +194,24 @@ public class GsonAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void withLenient() {
|
||||
this.contextRunner.withPropertyValues("spring.gson.lenient:true").run(context -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
/*
|
||||
* It seems that lenient setting not work in version 2.8.2. We get access to
|
||||
* it via reflection
|
||||
*/
|
||||
Field lenientField = gson.getClass().getDeclaredField("lenient");
|
||||
lenientField.setAccessible(true);
|
||||
boolean lenient = lenientField.getBoolean(gson);
|
||||
this.contextRunner.withPropertyValues("spring.gson.lenient:true")
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
/*
|
||||
* It seems that lenient setting not work in version 2.8.2. We get
|
||||
* access to it via reflection
|
||||
*/
|
||||
Field lenientField = gson.getClass().getDeclaredField("lenient");
|
||||
lenientField.setAccessible(true);
|
||||
boolean lenient = lenientField.getBoolean(gson);
|
||||
|
||||
assertThat(lenient).isTrue();
|
||||
});
|
||||
assertThat(lenient).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withHtmlEscaping() {
|
||||
this.contextRunner.run(context -> {
|
||||
this.contextRunner.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.htmlSafe()).isTrue();
|
||||
});
|
||||
@@ -219,7 +220,7 @@ public class GsonAutoConfigurationTests {
|
||||
@Test
|
||||
public void withoutHtmlEscaping() {
|
||||
this.contextRunner.withPropertyValues("spring.gson.disable-html-escaping:true")
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
assertThat(gson.htmlSafe()).isFalse();
|
||||
});
|
||||
@@ -229,7 +230,7 @@ public class GsonAutoConfigurationTests {
|
||||
@Test
|
||||
public void customDateFormat() {
|
||||
this.contextRunner.withPropertyValues("spring.gson.date-format:H")
|
||||
.run(context -> {
|
||||
.run((context) -> {
|
||||
Gson gson = context.getBean(Gson.class);
|
||||
DateTime dateTime = new DateTime(1988, 6, 25, 20, 30);
|
||||
Date date = dateTime.toDate();
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ package org.springframework.boot.web.embedded.undertow;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import io.undertow.Undertow;
|
||||
import io.undertow.Undertow.Builder;
|
||||
import io.undertow.servlet.api.DeploymentInfo;
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ public interface ConfigurableUndertowWebServerFactory {
|
||||
|
||||
/**
|
||||
* Add {@link UndertowBuilderCustomizer}s that should be used to customize the
|
||||
* Undertow {@link Undertow.Builder}.
|
||||
* Undertow {@link Builder}.
|
||||
* @param customizers the customizers to add
|
||||
*/
|
||||
void addBuilderCustomizers(UndertowBuilderCustomizer... customizers);
|
||||
|
||||
+1
-1
@@ -611,7 +611,7 @@ public class MapBinderTests {
|
||||
@Override
|
||||
public Map<String, String> convert(String s) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
StringUtils.commaDelimitedListToSet(s).forEach(k -> map.put(k, ""));
|
||||
StringUtils.commaDelimitedListToSet(s).forEach((k) -> map.put(k, ""));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user