Skip to content

Commit 8f44c89

Browse files
committed
Merge branch '3.5.x'
Closes gh-46801
2 parents b56403b + 78aac2f commit 8f44c89

File tree

6 files changed

+30
-37
lines changed

6 files changed

+30
-37
lines changed

buildSrc/src/test/java/org/springframework/boot/build/architecture/ArchitectureCheckTests.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void setup(@TempDir Path projectDir) {
5656
@Test
5757
void whenPackagesAreTangledTaskFailsAndWritesAReport() throws IOException {
5858
runGradleWithCompiledClasses("tangled",
59-
shouldHaveFailureReportWithMessage("slices matching '(**)' should be free of cycles"));
59+
shouldHaveFailureReportWithMessages("slices matching '(**)' should be free of cycles"));
6060
}
6161

6262
@Test
@@ -67,15 +67,15 @@ void whenPackagesAreNotTangledTaskSucceedsAndWritesAnEmptyReport() throws IOExce
6767
@Test
6868
void whenBeanPostProcessorBeanMethodIsNotStaticTaskFailsAndWritesAReport() throws IOException {
6969
runGradleWithCompiledClasses("bpp/nonstatic",
70-
shouldHaveFailureReportWithMessage(
70+
shouldHaveFailureReportWithMessages(
7171
"methods that are annotated with @Bean and have raw return type assignable "
7272
+ "to org.springframework.beans.factory.config.BeanPostProcessor"));
7373
}
7474

7575
@Test
7676
void whenBeanPostProcessorBeanMethodIsStaticAndHasUnsafeParametersTaskFailsAndWritesAReport() throws IOException {
7777
runGradleWithCompiledClasses("bpp/unsafeparameters",
78-
shouldHaveFailureReportWithMessage(
78+
shouldHaveFailureReportWithMessages(
7979
"methods that are annotated with @Bean and have raw return type assignable "
8080
+ "to org.springframework.beans.factory.config.BeanPostProcessor"));
8181
}
@@ -95,14 +95,14 @@ void whenBeanPostProcessorBeanMethodIsStaticAndHasNoParametersTaskSucceedsAndWri
9595
@Test
9696
void whenBeanFactoryPostProcessorBeanMethodIsNotStaticTaskFailsAndWritesAReport() throws IOException {
9797
runGradleWithCompiledClasses("bfpp/nonstatic",
98-
shouldHaveFailureReportWithMessage("methods that are annotated with @Bean and have raw return "
98+
shouldHaveFailureReportWithMessages("methods that are annotated with @Bean and have raw return "
9999
+ "type assignable to org.springframework.beans.factory.config.BeanFactoryPostProcessor"));
100100
}
101101

102102
@Test
103103
void whenBeanFactoryPostProcessorBeanMethodIsStaticAndHasParametersTaskFailsAndWritesAReport() throws IOException {
104104
runGradleWithCompiledClasses("bfpp/parameters",
105-
shouldHaveFailureReportWithMessage("methods that are annotated with @Bean and have raw return "
105+
shouldHaveFailureReportWithMessages("methods that are annotated with @Bean and have raw return "
106106
+ "type assignable to org.springframework.beans.factory.config.BeanFactoryPostProcessor"));
107107
}
108108

@@ -114,7 +114,7 @@ void whenBeanFactoryPostProcessorBeanMethodIsStaticAndHasNoParametersTaskSucceed
114114

115115
@Test
116116
void whenClassLoadsResourceUsingResourceUtilsTaskFailsAndWritesReport() throws IOException {
117-
runGradleWithCompiledClasses("resources/loads", shouldHaveFailureReportWithMessage(
117+
runGradleWithCompiledClasses("resources/loads", shouldHaveFailureReportWithMessages(
118118
"no classes should call method where target owner type org.springframework.util.ResourceUtils and target name 'getURL'"));
119119
}
120120

@@ -130,26 +130,26 @@ void whenClassDoesNotCallObjectsRequireNonNullTaskSucceedsAndWritesAnEmptyReport
130130

131131
@Test
132132
void whenClassCallsObjectsRequireNonNullWithMessageTaskFailsAndWritesReport() throws IOException {
133-
runGradleWithCompiledClasses("objects/requireNonNullWithString", shouldHaveFailureReportWithMessage(
133+
runGradleWithCompiledClasses("objects/requireNonNullWithString", shouldHaveFailureReportWithMessages(
134134
"no classes should call method Objects.requireNonNull(Object, String)"));
135135
}
136136

137137
@Test
138138
void whenClassCallsObjectsRequireNonNullWithSupplierTaskFailsAndWritesReport() throws IOException {
139-
runGradleWithCompiledClasses("objects/requireNonNullWithSupplier", shouldHaveFailureReportWithMessage(
139+
runGradleWithCompiledClasses("objects/requireNonNullWithSupplier", shouldHaveFailureReportWithMessages(
140140
"no classes should call method Objects.requireNonNull(Object, Supplier)"));
141141
}
142142

143143
@Test
144144
void whenClassCallsStringToUpperCaseWithoutLocaleFailsAndWritesReport() throws IOException {
145145
runGradleWithCompiledClasses("string/toUpperCase",
146-
shouldHaveFailureReportWithMessage("because String.toUpperCase(Locale.ROOT) should be used instead"));
146+
shouldHaveFailureReportWithMessages("because String.toUpperCase(Locale.ROOT) should be used instead"));
147147
}
148148

149149
@Test
150150
void whenClassCallsStringToLowerCaseWithoutLocaleFailsAndWritesReport() throws IOException {
151151
runGradleWithCompiledClasses("string/toLowerCase",
152-
shouldHaveFailureReportWithMessage("because String.toLowerCase(Locale.ROOT) should be used instead"));
152+
shouldHaveFailureReportWithMessages("because String.toLowerCase(Locale.ROOT) should be used instead"));
153153
}
154154

155155
@Test
@@ -164,7 +164,7 @@ void whenClassCallsStringToUpperCaseWithLocaleShouldNotFail() throws IOException
164164

165165
@Test
166166
void whenBeanMethodExposePrivateTypeShouldFailAndWriteReport() throws IOException {
167-
runGradleWithCompiledClasses("beans/privatebean", shouldHaveFailureReportWithMessage(
167+
runGradleWithCompiledClasses("beans/privatebean", shouldHaveFailureReportWithMessages(
168168
"methods that are annotated with @Bean should not return types declared with the PRIVATE modifier,"
169169
+ " as such types are incompatible with Spring AOT processing",
170170
"Method <org.springframework.boot.build.architecture.beans.privatebean.PrivateBean.myBean()> "
@@ -173,7 +173,7 @@ void whenBeanMethodExposePrivateTypeShouldFailAndWriteReport() throws IOExceptio
173173
}
174174

175175
@Test
176-
void whenBeanMethodExposeNonPrivateTypeeShouldNotFail() throws IOException {
176+
void whenBeanMethodExposeNonPrivateTypeShouldNotFail() throws IOException {
177177
runGradleWithCompiledClasses("beans/regular", shouldHaveEmptyFailureReport());
178178
}
179179

@@ -207,7 +207,7 @@ IntegrationMBeanExporter integrationMBeanExporter() {
207207
}
208208
}
209209
""");
210-
runGradle(shouldHaveFailureReportWithMessage("methods that are annotated with @Bean and have raw return "
210+
runGradle(shouldHaveFailureReportWithMessages("methods that are annotated with @Bean and have raw return "
211211
+ "type assignable to org.springframework.beans.factory.config.BeanPostProcessor "));
212212
}
213213

@@ -224,7 +224,7 @@ private Consumer<GradleRunner> shouldHaveEmptyFailureReport() {
224224
};
225225
}
226226

227-
private Consumer<GradleRunner> shouldHaveFailureReportWithMessage(String... messages) {
227+
private Consumer<GradleRunner> shouldHaveFailureReportWithMessages(String... messages) {
228228
return (gradleRunner) -> {
229229
assertThat(gradleRunner.buildAndFail().getOutput()).contains("BUILD FAILED")
230230
.contains("Task :checkArchitectureMain FAILED");

documentation/spring-boot-docs/src/main/kotlin/org/springframework/boot/docs/actuator/micrometertracing/gettingstarted/MyApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MyApplication {
3030
private val logger: Log = LogFactory.getLog(MyApplication::class.java)
3131

3232
@RequestMapping("/")
33-
fun hello(): String {
33+
fun home(): String {
3434
logger.info("home() has been called")
3535
return "Hello, World!"
3636
}

loader/spring-boot-loader/src/main/java/org/springframework/boot/loader/net/util/UrlDecoder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.HexFormat;
2222

2323
/**
24-
* Utility to decode URL strings. Copied frm Spring Framework's {@code StringUtils} as we
24+
* Utility to decode URL strings. Copied from Spring Framework's {@code StringUtils} as we
2525
* cannot depend on it in the loader.
2626
*
2727
* @author Phillip Webb
@@ -52,6 +52,7 @@ public static String decode(String source) {
5252
* @param charset the character encoding to use to decode the "<i>{@code %xy}</i>"
5353
* sequences
5454
* @return the decoded value
55+
* @since 4.0.0
5556
*/
5657
public static String decode(String source, Charset charset) {
5758
int length = source.length();

module/spring-boot-metrics/src/test/java/org/springframework/boot/metrics/autoconfigure/MetricsAspectsAutoConfigurationTests.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3232
import org.springframework.context.annotation.Bean;
3333
import org.springframework.context.annotation.Configuration;
34-
import org.springframework.test.util.ReflectionTestUtils;
3534

3635
import static org.assertj.core.api.Assertions.assertThat;
3736
import static org.mockito.Mockito.mock;
@@ -70,8 +69,7 @@ void shouldAutoConfigureMeterTagAnnotationHandlerWhenValueExpressionResolverIsAv
7069
this.contextRunner.withBean(ValueExpressionResolver.class, () -> mock(ValueExpressionResolver.class))
7170
.run((context) -> {
7271
assertThat(context).hasSingleBean(TimedAspect.class).hasSingleBean(MeterTagAnnotationHandler.class);
73-
assertThat(
74-
ReflectionTestUtils.getField(context.getBean(TimedAspect.class), "meterTagAnnotationHandler"))
72+
assertThat(context.getBean(TimedAspect.class)).extracting("meterTagAnnotationHandler")
7573
.isSameAs(context.getBean(MeterTagAnnotationHandler.class));
7674
});
7775
}
@@ -83,8 +81,7 @@ void shouldUseUserDefinedMeterTagAnnotationHandler() {
8381
() -> new MeterTagAnnotationHandler(null, null))
8482
.run((context) -> {
8583
assertThat(context).hasSingleBean(TimedAspect.class).hasSingleBean(MeterTagAnnotationHandler.class);
86-
assertThat(
87-
ReflectionTestUtils.getField(context.getBean(TimedAspect.class), "meterTagAnnotationHandler"))
84+
assertThat(context.getBean(TimedAspect.class)).extracting("meterTagAnnotationHandler")
8885
.isSameAs(context.getBean("customMeterTagAnnotationHandler"));
8986
});
9087
}
@@ -95,8 +92,7 @@ void shouldAutoConfigureCountedMeterTagAnnotationHandlerWhenValueExpressionResol
9592
.run((context) -> {
9693
assertThat(context).hasSingleBean(CountedAspect.class)
9794
.hasSingleBean(CountedMeterTagAnnotationHandler.class);
98-
assertThat(
99-
ReflectionTestUtils.getField(context.getBean(CountedAspect.class), "meterTagAnnotationHandler"))
95+
assertThat(context.getBean(CountedAspect.class)).extracting("meterTagAnnotationHandler")
10096
.isSameAs(context.getBean(CountedMeterTagAnnotationHandler.class));
10197
});
10298
}
@@ -109,8 +105,7 @@ void shouldUseUserDefinedCountedMeterTagAnnotationHandler() {
109105
.run((context) -> {
110106
assertThat(context).hasSingleBean(CountedAspect.class)
111107
.hasSingleBean(CountedMeterTagAnnotationHandler.class);
112-
assertThat(
113-
ReflectionTestUtils.getField(context.getBean(CountedAspect.class), "meterTagAnnotationHandler"))
108+
assertThat(context.getBean(CountedAspect.class)).extracting("meterTagAnnotationHandler")
114109
.isSameAs(context.getBean(CountedMeterTagAnnotationHandler.class));
115110
});
116111
}

module/spring-boot-metrics/src/test/java/org/springframework/boot/metrics/autoconfigure/export/stackdriver/StackdriverPropertiesConfigAdapterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void whenPropertiesMetricTypePrefixIsSetAdapterMetricTypePrefixReturnsIt() {
7878
}
7979

8080
@Test
81-
void whenPropertiesAutoCreateMetricDescriptorsIsSetAdapterAutoCreateMetricDescriptorReturnsIt() {
81+
void whenPropertiesAutoCreateMetricDescriptorsIsSetAdapterAutoCreateMetricDescriptorsReturnsIt() {
8282
StackdriverProperties properties = new StackdriverProperties();
8383
properties.setAutoCreateMetricDescriptors(false);
8484
assertThat(new StackdriverPropertiesConfigAdapter(properties).autoCreateMetricDescriptors()).isFalse();

module/spring-boot-tracing/src/test/java/org/springframework/boot/tracing/autoconfigure/TracingAndMeterObservationHandlerGroupTests.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import io.micrometer.tracing.Tracer;
2828
import io.micrometer.tracing.handler.TracingAwareMeterObservationHandler;
2929
import io.micrometer.tracing.handler.TracingObservationHandler;
30-
import org.assertj.core.extractor.Extractors;
30+
import org.assertj.core.api.InstanceOfAssertFactories;
3131
import org.junit.jupiter.api.Test;
3232
import org.mockito.ArgumentCaptor;
3333

@@ -63,7 +63,6 @@ void isMemberAcceptsMeterObservationHandlerOrTracingObservationHandler() {
6363
}
6464

6565
@Test
66-
@SuppressWarnings("unchecked")
6766
void registerMembersWrapsMeterObservationHandlersAndRegistersDistinctGroups() {
6867
Tracer tracer = mock(Tracer.class);
6968
TracingAndMeterObservationHandlerGroup group = new TracingAndMeterObservationHandlerGroup(tracer);
@@ -79,16 +78,14 @@ void registerMembersWrapsMeterObservationHandlersAndRegistersDistinctGroups() {
7978
List<ObservationHandler<?>> actualComposites = handlerCaptor.getAllValues();
8079
assertThat(actualComposites).hasSize(2);
8180
ObservationHandler<?> tracingComposite = actualComposites.get(0);
82-
assertThat(tracingComposite).isInstanceOf(FirstMatchingCompositeObservationHandler.class);
83-
List<ObservationHandler<?>> tracingHandlers = (List<ObservationHandler<?>>) Extractors.byName("handlers")
84-
.apply(tracingComposite);
85-
assertThat(tracingHandlers).containsExactly(tracingHandler1, tracingHandler2);
81+
assertThat(tracingComposite).isInstanceOf(FirstMatchingCompositeObservationHandler.class)
82+
.extracting("handlers", InstanceOfAssertFactories.LIST)
83+
.containsExactly(tracingHandler1, tracingHandler2);
8684
ObservationHandler<?> metricsComposite = actualComposites.get(1);
87-
assertThat(metricsComposite).isInstanceOf(FirstMatchingCompositeObservationHandler.class);
88-
List<ObservationHandler<?>> metricsHandlers = (List<ObservationHandler<?>>) Extractors.byName("handlers")
89-
.apply(metricsComposite);
90-
assertThat(metricsHandlers).hasSize(2);
91-
assertThat(metricsHandlers).extracting("delegate").containsExactly(meterHandler1, meterHandler2);
85+
assertThat(metricsComposite).isInstanceOf(FirstMatchingCompositeObservationHandler.class)
86+
.extracting("handlers", InstanceOfAssertFactories.LIST)
87+
.extracting("delegate")
88+
.containsExactly(meterHandler1, meterHandler2);
9289
}
9390

9491
@Test

0 commit comments

Comments
 (0)