Skip to content

Commit c1596c3

Browse files
committed
XWIKI-23171: Non interactive subwiki DW should be triggered when the main wiki DW is finished
* codestyle
1 parent 914a411 commit c1596c3

File tree

1 file changed

+33
-31
lines changed
  • xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-distribution/src/main/java/org/xwiki/extension/distribution/internal/job

1 file changed

+33
-31
lines changed

xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-distribution/src/main/java/org/xwiki/extension/distribution/internal/job/AbstractDistributionJob.java

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -259,37 +259,7 @@ protected void jobFinished(Throwable exception)
259259
&& wikis.isMainWiki(getWiki())) {
260260
try {
261261
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));
293263

294264
distributionJobThread.setDaemon(true);
295265
distributionJobThread.setName("Wikis non-interfactive distribution jobs");
@@ -300,6 +270,38 @@ public void run()
300270
}
301271
}
302272

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+
303305
private void signalReady()
304306
{
305307
this.lock.lock();

0 commit comments

Comments
 (0)