@@ -259,37 +259,7 @@ protected void jobFinished(Throwable exception)
259
259
&& wikis .isMainWiki (getWiki ())) {
260
260
try {
261
261
Collection <String > wikiIds = wikis .getAllIds ();
262
- Thread distributionJobThread = new Thread (new Runnable ()
263
- {
264
- @ Override
265
- public void run ()
266
- {
267
- // Create a clean Execution Context
268
- ExecutionContext context = new ExecutionContext ();
269
-
270
- try {
271
- executionContextManager .initialize (context );
272
- } catch (ExecutionContextException e ) {
273
- throw new RuntimeException ("Failed to initialize wiki distribution job execution context" ,
274
- e );
275
- }
276
-
277
- for (String wikiId : wikiIds ) {
278
- if (!wikis .isMainWiki (wikiId )) {
279
- try {
280
- // Trigger the wiki distribution job only if it's not the case already
281
- if (distributionManager .getWikiJob (wikiId ) == null ) {
282
- logger .info ("Start distribution job for wiki [{}]" , wikiId );
283
- distributionManager .startWikiJob (wikiId , false ).join ();
284
- logger .info ("Finished distribution job for wiki [{}]" , wikiId );
285
- }
286
- } catch (InterruptedException e ) {
287
- throw new RuntimeException (e );
288
- }
289
- }
290
- }
291
- }
292
- });
262
+ Thread distributionJobThread = new Thread (() -> runSubWikiDistributions (wikiIds , wikis ));
293
263
294
264
distributionJobThread .setDaemon (true );
295
265
distributionJobThread .setName ("Wikis non-interfactive distribution jobs" );
@@ -300,6 +270,38 @@ public void run()
300
270
}
301
271
}
302
272
273
+ private void runSubWikiDistributions (Collection <String > wikiIds , WikiDescriptorManager wikiManager )
274
+ {
275
+ // Create a clean Execution Context
276
+ ExecutionContext context = new ExecutionContext ();
277
+
278
+ try {
279
+ this .executionContextManager .initialize (context );
280
+ } catch (ExecutionContextException e ) {
281
+ throw new RuntimeException ("Failed to initialize wiki distribution job execution context" , e );
282
+ }
283
+
284
+ for (String wikiId : wikiIds ) {
285
+ if (!wikiManager .isMainWiki (wikiId )) {
286
+ try {
287
+ // Trigger the wiki distribution job only if it's not the case already
288
+ if (this .distributionManager .getWikiJob (wikiId ) == null ) {
289
+ this .logger .info ("Start distribution job for wiki [{}]" , wikiId );
290
+ this .distributionManager .startWikiJob (wikiId , false ).join ();
291
+ this .logger .info ("Finished distribution job for wiki [{}]" , wikiId );
292
+ }
293
+ } catch (InterruptedException e ) {
294
+ // Sonar is not a fan of InterruptedException catching, and apparently throwing it
295
+ // through a RuntimeException is not enough for it (but unfortunately we cannot
296
+ // really throw much else in a Runnable)
297
+ Thread .currentThread ().interrupt ();
298
+
299
+ throw new RuntimeException (e );
300
+ }
301
+ }
302
+ }
303
+ }
304
+
303
305
private void signalReady ()
304
306
{
305
307
this .lock .lock ();
0 commit comments