Skip to content

Commit d9ca263

Browse files
committed
Merge branch '6.1.x'
2 parents 3988974 + 05d9b52 commit d9ca263

File tree

8 files changed

+73
-50
lines changed

8 files changed

+73
-50
lines changed

Diff for: spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBeanRuntimeHints.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ class SchedulerFactoryBeanRuntimeHints implements RuntimeHintsRegistrar {
3737

3838
private static final String SCHEDULER_FACTORY_CLASS_NAME = "org.quartz.impl.StdSchedulerFactory";
3939

40-
private final ReflectiveRuntimeHintsRegistrar reflectiveRegistrar = new ReflectiveRuntimeHintsRegistrar();
40+
private static final ReflectiveRuntimeHintsRegistrar registrar = new ReflectiveRuntimeHintsRegistrar();
4141

4242

4343
@Override
@@ -49,7 +49,7 @@ public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader)
4949
.registerType(TypeReference.of(SCHEDULER_FACTORY_CLASS_NAME), this::typeHint)
5050
.registerTypes(TypeReference.listOf(ResourceLoaderClassLoadHelper.class,
5151
LocalTaskExecutorThreadPool.class, LocalDataSourceJobStore.class), this::typeHint);
52-
this.reflectiveRegistrar.registerRuntimeHints(hints, LocalTaskExecutorThreadPool.class);
52+
registrar.registerRuntimeHints(hints, LocalTaskExecutorThreadPool.class);
5353
}
5454

5555
private void typeHint(Builder typeHint) {

Diff for: spring-context/src/main/java/org/springframework/context/aot/ReflectiveProcessorBeanFactoryInitializationAotProcessor.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,8 @@
3939
*/
4040
class ReflectiveProcessorBeanFactoryInitializationAotProcessor implements BeanFactoryInitializationAotProcessor {
4141

42-
private static final ReflectiveRuntimeHintsRegistrar REGISTRAR = new ReflectiveRuntimeHintsRegistrar();
42+
private static final ReflectiveRuntimeHintsRegistrar registrar = new ReflectiveRuntimeHintsRegistrar();
43+
4344

4445
@Override
4546
public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) {
@@ -49,7 +50,9 @@ public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableL
4950
return new ReflectiveProcessorBeanFactoryInitializationAotContribution(beanTypes);
5051
}
5152

52-
private static class ReflectiveProcessorBeanFactoryInitializationAotContribution implements BeanFactoryInitializationAotContribution {
53+
54+
private static class ReflectiveProcessorBeanFactoryInitializationAotContribution
55+
implements BeanFactoryInitializationAotContribution {
5356

5457
private final Class<?>[] types;
5558

@@ -60,9 +63,8 @@ public ReflectiveProcessorBeanFactoryInitializationAotContribution(Class<?>[] ty
6063
@Override
6164
public void applyTo(GenerationContext generationContext, BeanFactoryInitializationCode beanFactoryInitializationCode) {
6265
RuntimeHints runtimeHints = generationContext.getRuntimeHints();
63-
REGISTRAR.registerRuntimeHints(runtimeHints, this.types);
66+
registrar.registerRuntimeHints(runtimeHints, this.types);
6467
}
65-
6668
}
6769

6870
}

Diff for: spring-core/src/main/java/org/springframework/aot/hint/annotation/Reflective.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@
3939
* @see ReflectiveRuntimeHintsRegistrar
4040
* @see RegisterReflectionForBinding @RegisterReflectionForBinding
4141
*/
42-
@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.CONSTRUCTOR,
43-
ElementType.FIELD, ElementType.METHOD })
42+
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD})
4443
@Retention(RetentionPolicy.RUNTIME)
4544
@Documented
4645
public @interface Reflective {

Diff for: spring-core/src/main/java/org/springframework/aot/hint/annotation/RegisterReflectionForBinding.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* <pre class="code">
3838
* &#064;Configuration
39-
* &#064;RegisterReflectionForBinding({ Foo.class, Bar.class })
39+
* &#064;RegisterReflectionForBinding({Foo.class, Bar.class})
4040
* public class MyConfig {
4141
* // ...
4242
* }</pre>
@@ -78,7 +78,7 @@
7878
/**
7979
* Classes for which reflection hints should be registered.
8080
* <p>At least one class must be specified either via {@link #value} or
81-
* {@link #classes}.
81+
* {@code #classes}.
8282
* @see #value()
8383
*/
8484
@AliasFor("value")

Diff for: spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java

+3
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
395395
else if (targetClass.isInstance(proxy)) {
396396
return proxy;
397397
}
398+
else {
399+
return this.target.unwrap(targetClass);
400+
}
398401
}
399402
case "getOutputParameterValue" -> {
400403
if (this.entityManager == null) {

Diff for: spring-orm/src/test/java/org/springframework/orm/jpa/SharedEntityManagerCreatorTests.java

+54-34
Original file line numberDiff line numberDiff line change
@@ -105,75 +105,95 @@ void transactionRequiredExceptionOnRefresh() {
105105
void deferredQueryWithUpdate() {
106106
EntityManagerFactory emf = mock();
107107
EntityManager targetEm = mock();
108-
Query query = mock();
108+
Query targetQuery = mock();
109109
given(emf.createEntityManager()).willReturn(targetEm);
110-
given(targetEm.createQuery("x")).willReturn(query);
110+
given(targetEm.createQuery("x")).willReturn(targetQuery);
111111
given(targetEm.isOpen()).willReturn(true);
112+
given((Query) targetQuery.unwrap(targetQuery.getClass())).willReturn(targetQuery);
112113

113114
EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(emf);
114-
em.createQuery("x").executeUpdate();
115+
Query query = em.createQuery("x");
116+
assertThat((Query) query.unwrap(null)).isSameAs(targetQuery);
117+
assertThat((Query) query.unwrap(targetQuery.getClass())).isSameAs(targetQuery);
118+
assertThat(query.unwrap(Query.class)).isSameAs(query);
119+
query.executeUpdate();
115120

116-
verify(query).executeUpdate();
121+
verify(targetQuery).executeUpdate();
117122
verify(targetEm).close();
118123
}
119124

120125
@Test
121126
void deferredQueryWithSingleResult() {
122127
EntityManagerFactory emf = mock();
123128
EntityManager targetEm = mock();
124-
Query query = mock();
129+
Query targetQuery = mock();
125130
given(emf.createEntityManager()).willReturn(targetEm);
126-
given(targetEm.createQuery("x")).willReturn(query);
131+
given(targetEm.createQuery("x")).willReturn(targetQuery);
127132
given(targetEm.isOpen()).willReturn(true);
133+
given((Query) targetQuery.unwrap(targetQuery.getClass())).willReturn(targetQuery);
128134

129135
EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(emf);
130-
em.createQuery("x").getSingleResult();
136+
Query query = em.createQuery("x");
137+
assertThat((Query) query.unwrap(null)).isSameAs(targetQuery);
138+
assertThat((Query) query.unwrap(targetQuery.getClass())).isSameAs(targetQuery);
139+
assertThat(query.unwrap(Query.class)).isSameAs(query);
140+
query.getSingleResult();
131141

132-
verify(query).getSingleResult();
142+
verify(targetQuery).getSingleResult();
133143
verify(targetEm).close();
134144
}
135145

136146
@Test
137147
void deferredQueryWithResultList() {
138148
EntityManagerFactory emf = mock();
139149
EntityManager targetEm = mock();
140-
Query query = mock();
150+
Query targetQuery = mock();
141151
given(emf.createEntityManager()).willReturn(targetEm);
142-
given(targetEm.createQuery("x")).willReturn(query);
152+
given(targetEm.createQuery("x")).willReturn(targetQuery);
143153
given(targetEm.isOpen()).willReturn(true);
154+
given((Query) targetQuery.unwrap(targetQuery.getClass())).willReturn(targetQuery);
144155

145156
EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(emf);
146-
em.createQuery("x").getResultList();
157+
Query query = em.createQuery("x");
158+
assertThat((Query) query.unwrap(null)).isSameAs(targetQuery);
159+
assertThat((Query) query.unwrap(targetQuery.getClass())).isSameAs(targetQuery);
160+
assertThat(query.unwrap(Query.class)).isSameAs(query);
161+
query.getResultList();
147162

148-
verify(query).getResultList();
163+
verify(targetQuery).getResultList();
149164
verify(targetEm).close();
150165
}
151166

152167
@Test
153168
void deferredQueryWithResultStream() {
154169
EntityManagerFactory emf = mock();
155170
EntityManager targetEm = mock();
156-
Query query = mock();
171+
Query targetQuery = mock();
157172
given(emf.createEntityManager()).willReturn(targetEm);
158-
given(targetEm.createQuery("x")).willReturn(query);
173+
given(targetEm.createQuery("x")).willReturn(targetQuery);
159174
given(targetEm.isOpen()).willReturn(true);
175+
given((Query) targetQuery.unwrap(targetQuery.getClass())).willReturn(targetQuery);
160176

161177
EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(emf);
162-
em.createQuery("x").getResultStream();
178+
Query query = em.createQuery("x");
179+
assertThat((Query) query.unwrap(null)).isSameAs(targetQuery);
180+
assertThat((Query) query.unwrap(targetQuery.getClass())).isSameAs(targetQuery);
181+
assertThat(query.unwrap(Query.class)).isSameAs(query);
182+
query.getResultStream();
163183

164-
verify(query).getResultStream();
184+
verify(targetQuery).getResultStream();
165185
verify(targetEm).close();
166186
}
167187

168188
@Test
169189
void deferredStoredProcedureQueryWithIndexedParameters() {
170190
EntityManagerFactory emf = mock();
171191
EntityManager targetEm = mock();
172-
StoredProcedureQuery query = mock();
192+
StoredProcedureQuery targetQuery = mock();
173193
given(emf.createEntityManager()).willReturn(targetEm);
174-
given(targetEm.createStoredProcedureQuery("x")).willReturn(query);
175-
willReturn("y").given(query).getOutputParameterValue(0);
176-
willReturn("z").given(query).getOutputParameterValue(2);
194+
given(targetEm.createStoredProcedureQuery("x")).willReturn(targetQuery);
195+
willReturn("y").given(targetQuery).getOutputParameterValue(0);
196+
willReturn("z").given(targetQuery).getOutputParameterValue(2);
177197
given(targetEm.isOpen()).willReturn(true);
178198

179199
EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(emf);
@@ -187,24 +207,24 @@ void deferredStoredProcedureQueryWithIndexedParameters() {
187207
spq.getOutputParameterValue(1));
188208
assertThat(spq.getOutputParameterValue(2)).isEqualTo("z");
189209

190-
verify(query).registerStoredProcedureParameter(0, String.class, ParameterMode.OUT);
191-
verify(query).registerStoredProcedureParameter(1, Number.class, ParameterMode.IN);
192-
verify(query).registerStoredProcedureParameter(2, Object.class, ParameterMode.INOUT);
193-
verify(query).execute();
210+
verify(targetQuery).registerStoredProcedureParameter(0, String.class, ParameterMode.OUT);
211+
verify(targetQuery).registerStoredProcedureParameter(1, Number.class, ParameterMode.IN);
212+
verify(targetQuery).registerStoredProcedureParameter(2, Object.class, ParameterMode.INOUT);
213+
verify(targetQuery).execute();
194214
verify(targetEm).close();
195-
verifyNoMoreInteractions(query);
215+
verifyNoMoreInteractions(targetQuery);
196216
verifyNoMoreInteractions(targetEm);
197217
}
198218

199219
@Test
200220
void deferredStoredProcedureQueryWithNamedParameters() {
201221
EntityManagerFactory emf = mock();
202222
EntityManager targetEm = mock();
203-
StoredProcedureQuery query = mock();
223+
StoredProcedureQuery targetQuery = mock();
204224
given(emf.createEntityManager()).willReturn(targetEm);
205-
given(targetEm.createStoredProcedureQuery("x")).willReturn(query);
206-
willReturn("y").given(query).getOutputParameterValue("a");
207-
willReturn("z").given(query).getOutputParameterValue("c");
225+
given(targetEm.createStoredProcedureQuery("x")).willReturn(targetQuery);
226+
willReturn("y").given(targetQuery).getOutputParameterValue("a");
227+
willReturn("z").given(targetQuery).getOutputParameterValue("c");
208228
given(targetEm.isOpen()).willReturn(true);
209229

210230
EntityManager em = SharedEntityManagerCreator.createSharedEntityManager(emf);
@@ -218,12 +238,12 @@ void deferredStoredProcedureQueryWithNamedParameters() {
218238
spq.getOutputParameterValue("b"));
219239
assertThat(spq.getOutputParameterValue("c")).isEqualTo("z");
220240

221-
verify(query).registerStoredProcedureParameter("a", String.class, ParameterMode.OUT);
222-
verify(query).registerStoredProcedureParameter("b", Number.class, ParameterMode.IN);
223-
verify(query).registerStoredProcedureParameter("c", Object.class, ParameterMode.INOUT);
224-
verify(query).execute();
241+
verify(targetQuery).registerStoredProcedureParameter("a", String.class, ParameterMode.OUT);
242+
verify(targetQuery).registerStoredProcedureParameter("b", Number.class, ParameterMode.IN);
243+
verify(targetQuery).registerStoredProcedureParameter("c", Object.class, ParameterMode.INOUT);
244+
verify(targetQuery).execute();
225245
verify(targetEm).close();
226-
verifyNoMoreInteractions(query);
246+
verifyNoMoreInteractions(targetQuery);
227247
verifyNoMoreInteractions(targetEm);
228248
}
229249

Diff for: spring-web/src/main/java/org/springframework/web/client/NoOpResponseErrorHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public boolean hasError(ClientHttpResponse response) throws IOException {
3636

3737
@Override
3838
public void handleError(ClientHttpResponse response) throws IOException {
39-
39+
// never actually called
4040
}
4141

4242
}

Diff for: spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -481,7 +481,6 @@ private static class ForwardedHeaderExtractingResponse extends HttpServletRespon
481481

482482
@Override
483483
public void sendRedirect(String location) throws IOException {
484-
485484
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(location);
486485
UriComponents uriComponents = builder.build();
487486

0 commit comments

Comments
 (0)