@@ -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