From 502b4cf58abb5fda701ae0cc69474d544ec642a5 Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 31 Mar 2022 17:24:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-68726=20=E3=80=90=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E3=80=90=E6=95=B0=E6=8D=AE=E9=9B=86=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=91=E5=A4=9A=E5=BC=A0=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=A7=A6=E5=8F=91=E6=90=9C=E7=B4=A2=EF=BC=8C?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=A6=82=E7=8E=87=E5=8D=A1=E4=BD=8F?= =?UTF-8?q?=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E7=9A=84=E5=AE=9A=E6=97=B6=E5=99=A8=E6=AF=8F?= =?UTF-8?q?=E6=AC=A1=E6=90=9C=E7=B4=A2=E9=83=BD=E4=BC=9A=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=EF=BC=8C=E7=84=B6=E5=90=8E=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0+=E7=BA=BF=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E6=90=9C=E7=B4=A2=E5=AE=8C=E5=90=8E=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=E5=B0=86=E7=BA=BF=E7=A8=8B=E6=B1=A0shutDownN?= =?UTF-8?q?ow=EF=BC=8C=E6=98=AF=E4=B8=BA=E4=BA=86=E4=B8=8D=E8=AE=A9?= =?UTF-8?q?=E5=89=8D=E4=B8=80=E6=AC=A1=E7=9A=84=E6=90=9C=E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/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/TableDataTreeSearchManager.java | 4 +++- .../searcher/TableDataTreeSearcher.java | 2 +- .../search/time/TableDataSearchTimer.java | 22 ++++++++++++++----- .../search/time/TableDataSearchTimerTask.java | 3 ++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java index bb98fdeffa..e174cd16fc 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/TableDataTreeSearchManager.java @@ -131,7 +131,7 @@ public class TableDataTreeSearchManager { * @param searchText */ public void startSearch(String searchText) { - if (isRepeatSearch(searchText)) { + if (isRepeatSearch(searchText) || StringUtils.isEmpty(searchText)) { return; } setTreeSearchStatus(TreeSearchStatus.SEARCHING); @@ -196,6 +196,7 @@ public class TableDataTreeSearchManager { */ public void restoreToolBarAndTreePane() { setTreeSearchStatus(TreeSearchStatus.NOT_IN_SEARCH_MODE); + TableDataSearchTimer.getInstance().stopClock(); if (treeSearcher != null) { treeSearcher.afterSearch(); } @@ -210,6 +211,7 @@ public class TableDataTreeSearchManager { */ public void restoreTreePane() { setTreeSearchStatus(TreeSearchStatus.SEARCH_NOT_BEGIN); + TableDataSearchTimer.getInstance().stopClock(); lastSearchText = null; if (rendererHelper != null) { rendererHelper.restore(getCurrentTableDataTree()); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TableDataTreeSearcher.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TableDataTreeSearcher.java index 160d462b47..4d9d458c95 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TableDataTreeSearcher.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/searcher/TableDataTreeSearcher.java @@ -75,7 +75,7 @@ public class TableDataTreeSearcher implements TreeSearcher { * @param tableDataSource */ public void beforeSearch(TableDataSearchMode searchMode, TableDataSource tableDataSource) { - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new NamedThreadFactory(TableDataTreeSearchManager.class)); + executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new NamedThreadFactory(TableDataTreeSearcher.class)); collectTableDataWrappers(searchMode, tableDataSource); preCalculateColumns(); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java index 88c305e98b..1b6057983f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java @@ -1,6 +1,9 @@ package com.fr.design.data.datapane.management.search.time; import com.fr.concurrent.NamedThreadFactory; +import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; +import com.fr.third.org.apache.commons.lang3.ObjectUtils; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -16,7 +19,7 @@ public class TableDataSearchTimer { /** * 定时器 */ - private ScheduledExecutorService scheduler; + private static ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory(TableDataSearchTimer.class)); /** * 定时任务 @@ -40,15 +43,24 @@ public class TableDataSearchTimer { } public void startClock() { - this.scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory(TableDataSearchTimer.class)); this.timeTask = new TableDataSearchTimerTask(); scheduler.schedule(timeTask, MAX_SEARCH_TIME, TimeUnit.MILLISECONDS); } public void stopClock() { this.timeTask = null; - if (this.scheduler != null) { - this.scheduler.shutdownNow(); - } + } + + public void shutdown() { + scheduler.shutdown(); + } + + /** + * 判断是不是当前的Timer中的task,为了避免shutdownNow()之后原task仍在执行,可能会 + * @param task + * @return + */ + public boolean isCurrentTask(TableDataSearchTimerTask task) { + return ComparatorUtils.equals(this.timeTask, task); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimerTask.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimerTask.java index 65c2a04580..27b074f7e3 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimerTask.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimerTask.java @@ -14,7 +14,8 @@ public class TableDataSearchTimerTask implements Runnable { @Override public void run() { // 最大单次搜索时间过后,将结束搜索 - if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() == TreeSearchStatus.SEARCHING) { + if (TableDataTreeSearchManager.getInstance().getTreeSearchStatus() == TreeSearchStatus.SEARCHING && + TableDataSearchTimer.getInstance().isCurrentTask(this)) { TableDataTreeSearchManager.getInstance().completeSearch(); } } From aaa7944836852016a8f5e2b170963cdadae4400d Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 31 Mar 2022 17:26:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-68726=20=E5=88=A0=E6=8E=89=E5=A4=9A?= =?UTF-8?q?=E4=BD=99import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/management/search/time/TableDataSearchTimer.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java index 1b6057983f..63f041359d 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/time/TableDataSearchTimer.java @@ -2,8 +2,6 @@ package com.fr.design.data.datapane.management.search.time; import com.fr.concurrent.NamedThreadFactory; import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralUtils; -import com.fr.third.org.apache.commons.lang3.ObjectUtils; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService;