Skip to content

Commit 8bc99fa

Browse files
committed
Merge branch '6.2.x'
2 parents 4283a34 + ffd1515 commit 8bc99fa

File tree

4 files changed

+46
-34
lines changed

4 files changed

+46
-34
lines changed

Diff for: buildSrc/src/main/java/org/springframework/build/CheckstyleConventions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void apply(Project project) {
5050
project.getPlugins().apply(CheckstylePlugin.class);
5151
project.getTasks().withType(Checkstyle.class).forEach(checkstyle -> checkstyle.getMaxHeapSize().set("1g"));
5252
CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class);
53-
checkstyle.setToolVersion("10.22.0");
53+
checkstyle.setToolVersion("10.23.0");
5454
checkstyle.getConfigDirectory().set(project.getRootProject().file("src/checkstyle"));
5555
String version = SpringJavaFormatPlugin.class.getPackage().getImplementationVersion();
5656
DependencySet checkstyleDependencies = project.getConfigurations().getByName("checkstyle").getDependencies();

Diff for: framework-platform/framework-platform.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies {
2020
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.1"))
2121
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.8.0"))
2222
api(platform("org.junit:junit-bom:5.12.1"))
23-
api(platform("org.mockito:mockito-bom:5.16.1"))
23+
api(platform("org.mockito:mockito-bom:5.17.0"))
2424

2525
constraints {
2626
api("com.fasterxml:aalto-xml:1.3.2")

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) {
313313
while ((singletonObject = this.singletonObjects.get(beanName)) == null) {
314314
Thread otherThread = this.currentCreationThreads.get(beanName);
315315
if (otherThread != null && (otherThread == currentThread ||
316-
this.lenientWaitingThreads.get(otherThread) == currentThread)) {
316+
checkDependentWaitingThreads(otherThread, currentThread))) {
317317
throw ex;
318318
}
319319
if (!this.singletonsInLenientCreation.contains(beanName)) {
@@ -429,6 +429,16 @@ public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) {
429429
}
430430
}
431431

432+
private boolean checkDependentWaitingThreads(Thread waitingThread, Thread candidateThread) {
433+
Thread threadToCheck = waitingThread;
434+
while ((threadToCheck = this.lenientWaitingThreads.get(threadToCheck)) != null) {
435+
if (threadToCheck == candidateThread) {
436+
return true;
437+
}
438+
}
439+
return false;
440+
}
441+
432442
/**
433443
* Determine whether the current thread is allowed to hold the singleton lock.
434444
* <p>By default, any thread may acquire and hold the singleton lock, except

Diff for: spring-context/src/test/java/org/springframework/context/annotation/BackgroundBootstrapTests.java

+33-31
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public TestBean testBean1(ObjectProvider<TestBean> testBean2) {
139139
Thread.sleep(1000);
140140
}
141141
catch (InterruptedException ex) {
142-
throw new RuntimeException(ex);
142+
Thread.currentThread().interrupt();
143143
}
144144
return new TestBean();
145145
}
@@ -150,7 +150,7 @@ public TestBean testBean2() {
150150
Thread.sleep(2000);
151151
}
152152
catch (InterruptedException ex) {
153-
throw new RuntimeException(ex);
153+
Thread.currentThread().interrupt();
154154
}
155155
return new TestBean();
156156
}
@@ -170,7 +170,7 @@ public TestBean testBean1(ObjectProvider<TestBean> testBean3, ObjectProvider<Tes
170170
Thread.sleep(1000);
171171
}
172172
catch (InterruptedException ex) {
173-
throw new RuntimeException(ex);
173+
Thread.currentThread().interrupt();
174174
}
175175
return new TestBean();
176176
}
@@ -191,7 +191,7 @@ public TestBean testBean4() {
191191
Thread.sleep(2000);
192192
}
193193
catch (InterruptedException ex) {
194-
throw new RuntimeException(ex);
194+
Thread.currentThread().interrupt();
195195
}
196196
return new TestBean();
197197
}
@@ -208,7 +208,7 @@ public TestBean testBean1(ObjectProvider<TestBean> testBean2) {
208208
Thread.sleep(1000);
209209
}
210210
catch (InterruptedException ex) {
211-
throw new RuntimeException(ex);
211+
Thread.currentThread().interrupt();
212212
}
213213
return new TestBean("testBean1");
214214
}
@@ -230,7 +230,7 @@ public TestBean testBean1(ObjectProvider<TestBean> testBean2) {
230230
Thread.sleep(1000);
231231
}
232232
catch (InterruptedException ex) {
233-
throw new RuntimeException(ex);
233+
Thread.currentThread().interrupt();
234234
}
235235
return new TestBean();
236236
}
@@ -241,7 +241,7 @@ public TestBean testBean2(TestBean testBean1) {
241241
Thread.sleep(2000);
242242
}
243243
catch (InterruptedException ex) {
244-
throw new RuntimeException(ex);
244+
Thread.currentThread().interrupt();
245245
}
246246
return new TestBean();
247247
}
@@ -253,37 +253,25 @@ static class CircularReferenceWithBlockingMainThreadBeanConfig {
253253

254254
@Bean
255255
public TestBean testBean1(ObjectProvider<TestBean> testBean2) {
256-
Thread thread = new Thread(testBean2::getObject);
257-
thread.setUncaughtExceptionHandler((t, ex) -> System.out.println(System.currentTimeMillis() + " " + ex + " " + t));
258-
thread.start();
256+
new Thread(testBean2::getObject).start();
259257
try {
260258
Thread.sleep(1000);
261259
}
262260
catch (InterruptedException ex) {
263-
throw new RuntimeException(ex);
261+
Thread.currentThread().interrupt();
264262
}
265263
return new TestBean(testBean2.getObject());
266264
}
267265

268266
@Bean
269267
public TestBean testBean2(ObjectProvider<TestBean> testBean1) {
270-
System.out.println(System.currentTimeMillis() + " testBean2 begin " + Thread.currentThread());
271268
try {
272269
Thread.sleep(2000);
273270
}
274271
catch (InterruptedException ex) {
275-
throw new RuntimeException(ex);
276-
}
277-
try {
278-
return new TestBean(testBean1.getObject());
279-
}
280-
catch (RuntimeException ex) {
281-
System.out.println(System.currentTimeMillis() + " testBean2 exception " + Thread.currentThread());
282-
throw ex;
283-
}
284-
finally {
285-
System.out.println(System.currentTimeMillis() + " testBean2 end " + Thread.currentThread());
272+
Thread.currentThread().interrupt();
286273
}
274+
return new TestBean(testBean1.getObject());
287275
}
288276
}
289277

@@ -298,7 +286,7 @@ public TestBean testBean1(ObjectProvider<TestBean> testBean2) {
298286
Thread.sleep(1000);
299287
}
300288
catch (InterruptedException ex) {
301-
throw new RuntimeException(ex);
289+
Thread.currentThread().interrupt();
302290
}
303291
return new TestBean();
304292
}
@@ -309,7 +297,7 @@ public TestBean testBean2(TestBean testBean3) {
309297
Thread.sleep(2000);
310298
}
311299
catch (InterruptedException ex) {
312-
throw new RuntimeException(ex);
300+
Thread.currentThread().interrupt();
313301
}
314302
return new TestBean();
315303
}
@@ -325,14 +313,17 @@ public TestBean testBean3(TestBean testBean2) {
325313
static class CircularReferenceInMultipleThreadsBeanConfig {
326314

327315
@Bean
328-
public TestBean testBean1(ObjectProvider<TestBean> testBean2, ObjectProvider<TestBean> testBean3) {
316+
public TestBean testBean1(ObjectProvider<TestBean> testBean2, ObjectProvider<TestBean> testBean3,
317+
ObjectProvider<TestBean> testBean4) {
318+
329319
new Thread(testBean2::getObject).start();
330320
new Thread(testBean3::getObject).start();
321+
new Thread(testBean4::getObject).start();
331322
try {
332-
Thread.sleep(2000);
323+
Thread.sleep(3000);
333324
}
334325
catch (InterruptedException ex) {
335-
throw new RuntimeException(ex);
326+
Thread.currentThread().interrupt();
336327
}
337328
return new TestBean();
338329
}
@@ -343,18 +334,29 @@ public TestBean testBean2(ObjectProvider<TestBean> testBean3) {
343334
Thread.sleep(1000);
344335
}
345336
catch (InterruptedException ex) {
346-
throw new RuntimeException(ex);
337+
Thread.currentThread().interrupt();
347338
}
348339
return new TestBean(testBean3.getObject());
349340
}
350341

351342
@Bean
352-
public TestBean testBean3(ObjectProvider<TestBean> testBean2) {
343+
public TestBean testBean3(ObjectProvider<TestBean> testBean4) {
344+
try {
345+
Thread.sleep(1000);
346+
}
347+
catch (InterruptedException ex) {
348+
Thread.currentThread().interrupt();
349+
}
350+
return new TestBean(testBean4.getObject());
351+
}
352+
353+
@Bean
354+
public TestBean testBean4(ObjectProvider<TestBean> testBean2) {
353355
try {
354356
Thread.sleep(1000);
355357
}
356358
catch (InterruptedException ex) {
357-
throw new RuntimeException(ex);
359+
Thread.currentThread().interrupt();
358360
}
359361
return new TestBean(testBean2.getObject());
360362
}

0 commit comments

Comments
 (0)