From 372d7cc3681aa3ad8ce1371881071280f188e663 Mon Sep 17 00:00:00 2001 From: datagear Date: Fri, 5 Jul 2019 19:52:41 +0800 Subject: [PATCH] =?UTF-8?q?[dataexchange]=E5=AE=8C=E5=96=84DefaultBatchDat?= =?UTF-8?q?aExchangeContext=E7=B1=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DefaultBatchDataExchangeContext.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/datagear-dataexchange/src/main/java/org/datagear/dataexchange/DefaultBatchDataExchangeContext.java b/datagear-dataexchange/src/main/java/org/datagear/dataexchange/DefaultBatchDataExchangeContext.java index 384a7dea..3c3c139b 100644 --- a/datagear-dataexchange/src/main/java/org/datagear/dataexchange/DefaultBatchDataExchangeContext.java +++ b/datagear-dataexchange/src/main/java/org/datagear/dataexchange/DefaultBatchDataExchangeContext.java @@ -203,12 +203,10 @@ public class DefaultBatchDataExchangeContext implements BatchDataExchangeContext /** * 子数据交换任务取消后续处理。 * - * @param task + * @param subDataExchange */ - protected void forCancel(SubDataExchangeFutureTask task) + protected void forCancel(SubDataExchange subDataExchange) { - SubDataExchange subDataExchange = task.getSubDataExchange(); - Set cancelleds = new HashSet(); synchronized (this._subLock) @@ -231,12 +229,10 @@ public class DefaultBatchDataExchangeContext implements BatchDataExchangeContext /** * 子数据交换任务完成后续处理。 * - * @param task + * @param subDataExchange */ - protected void forFinish(SubDataExchangeFutureTask task) + protected void forFinish(SubDataExchange subDataExchange) { - SubDataExchange subDataExchange = task.getSubDataExchange(); - synchronized (this._subLock) { this._finishes.add(subDataExchange); @@ -468,13 +464,13 @@ public class DefaultBatchDataExchangeContext implements BatchDataExchangeContext @Override protected void done() { + boolean run = this._run.get(); + // XXX 执行中的任务,调用cancel后,isCancelled()仍会是true!! - boolean isCanceled = (isCancelled() && !_run.get()); + boolean isCanceled = (isCancelled() && !run); if (isCanceled) - DefaultBatchDataExchangeContext.this.forCancel(this); - else - DefaultBatchDataExchangeContext.this.forFinish(this); + DefaultBatchDataExchangeContext.this.forCancel(this.subDataExchange); } } @@ -503,8 +499,15 @@ public class DefaultBatchDataExchangeContext implements BatchDataExchangeContext @Override public void run() { - ((DataExchangeService) DefaultBatchDataExchangeContext.this.subDataExchangeService) - .exchange(this.subDataExchange.getDataExchange()); + try + { + ((DataExchangeService) DefaultBatchDataExchangeContext.this.subDataExchangeService) + .exchange(this.subDataExchange.getDataExchange()); + } + finally + { + DefaultBatchDataExchangeContext.this.forFinish(this.subDataExchange); + } } } }