From d51c4665337eab2df6cd32386352e8a91741f857 Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 14 Apr 2022 18:12:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-69776=20=E5=88=87=E6=8D=A2=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=BB=84=E4=BB=B6=E7=9A=84=E6=8E=92=E5=BA=8F=EF=BC=8C?= =?UTF-8?q?=E4=BC=9A=E5=8A=A0=E8=BD=BD=E5=BE=88=E4=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 使用了固定容量阻塞列表,导致资源加载阻塞 【改动思路】 使用LinkedBlockingQueue 【review建议】 --- .../ui/online/resource/OnlineResourceManager.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java index b29ea11db..ecdea13fe 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java @@ -1,8 +1,8 @@ package com.fr.design.mainframe.share.ui.online.resource; import javax.swing.SwingWorker; -import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; import java.util.function.Predicate; /** @@ -24,7 +24,7 @@ public class OnlineResourceManager { private SwingWorker swingWorker; - private final BlockingQueue loaderBlockingQueue = new ArrayBlockingQueue(100); + private final BlockingQueue loaderBlockingQueue = new LinkedBlockingQueue<>(); public void cancelLoad(Object key) { if (swingWorker != null) { @@ -39,11 +39,7 @@ public class OnlineResourceManager { } public void addLoader(ResourceLoader loader) { - try { - this.loaderBlockingQueue.put(loader); - } catch (InterruptedException e) { - e.printStackTrace(); - } + this.loaderBlockingQueue.add(loader); } public void loadImage() { From 73df50d5254ea3ec81d97595de66f4bc41312f8e Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 12 Apr 2022 10:42:56 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-69575=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E7=BB=84=E4=BB=B6=E5=88=B7=E4=B8=8D=E5=87=BA?= =?UTF-8?q?=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 oss服务器上缺少部分组件的封面图且读取文件时因为异常类型不匹配, 导致没有捕获到对应的异常,进而影响到组件面板的初始化,最终导致 子进程运行失败,没有切出加载界面。 【改动思路】 1. 组件面板延迟加载,不要影响组件包面板,以及整个在线组件库面板的展示 2. 使用Exception捕获封面图的读取异常 【review建议】 --- .../share/ui/block/AbstractOnlineWidgetBlock.java | 7 ++++--- .../mainframe/share/ui/online/OnlineWidgetTabPane.java | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java index 5c1620ab4..e4a978d52 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java @@ -23,7 +23,6 @@ import javax.swing.JPopupMenu; import java.awt.Dimension; import java.awt.Image; import java.awt.event.MouseEvent; -import java.io.IOException; import java.net.URL; /** @@ -75,7 +74,8 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock tabChangeListeners; private OnlineEmbedFilterShowPane embedFilterShowPane; private OnlineWidgetPackagesShowPane widgetPackagesShowPane; @@ -57,8 +58,6 @@ public class OnlineWidgetTabPane extends JPanel { this.cardLayout = new CardLayout(); this.centerPane = new JPanel(cardLayout); - this.centerPane.add(new OnlineWidgetShowPane(sharableWidgets), COMPONENT); - this.centerPane.add( embedFilterShowPane = new OnlineEmbedFilterShowPane(new OnlineWidgetShowPane(sharableWidgets, OnlineWidgetSortType.SALES)), COMPONENT_EMBED); //延迟组件包面板的初始化,防止组件面板里组件的缩略图和组件包面板里组件的缩略图一起加载 this.headGroup = new UITabGroup(new String[]{COMPONENT_PACKAGE, COMPONENT}) { public void tabChanged(int newSelectedIndex) { @@ -66,6 +65,12 @@ public class OnlineWidgetTabPane extends JPanel { changeListener.tabChange(newSelectedIndex); } if (newSelectedIndex == COMPONENT_TAB_INDEX) { + //延迟组件包面板的初始化,防止组件面板里组件和缩略图和组件包面板里组件的缩略图一起加载 + if (!componentPaneCreated) { + centerPane.add(new OnlineWidgetShowPane(sharableWidgets), COMPONENT); + centerPane.add( embedFilterShowPane = new OnlineEmbedFilterShowPane(new OnlineWidgetShowPane(sharableWidgets, OnlineWidgetSortType.SALES)), COMPONENT_EMBED); + componentPaneCreated = true; + } cardLayout.show(centerPane, ComponentShareUtil.needShowEmbedFilterPane() ? COMPONENT_EMBED : COMPONENT); } else { ComponentShareUtil.completeEmbedFilter(); From 61fdc8f64d13dd9a349584e595c12c1a03cb6c73 Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 14 Apr 2022 18:12:00 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-69776=20=E5=88=87=E6=8D=A2=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=BB=84=E4=BB=B6=E7=9A=84=E6=8E=92=E5=BA=8F=EF=BC=8C?= =?UTF-8?q?=E4=BC=9A=E5=8A=A0=E8=BD=BD=E5=BE=88=E4=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 使用了固定容量阻塞列表,导致资源加载阻塞 【改动思路】 使用LinkedBlockingQueue 【review建议】 --- .../ui/online/resource/OnlineResourceManager.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java index b29ea11db..ecdea13fe 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/resource/OnlineResourceManager.java @@ -1,8 +1,8 @@ package com.fr.design.mainframe.share.ui.online.resource; import javax.swing.SwingWorker; -import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; import java.util.function.Predicate; /** @@ -24,7 +24,7 @@ public class OnlineResourceManager { private SwingWorker swingWorker; - private final BlockingQueue loaderBlockingQueue = new ArrayBlockingQueue(100); + private final BlockingQueue loaderBlockingQueue = new LinkedBlockingQueue<>(); public void cancelLoad(Object key) { if (swingWorker != null) { @@ -39,11 +39,7 @@ public class OnlineResourceManager { } public void addLoader(ResourceLoader loader) { - try { - this.loaderBlockingQueue.put(loader); - } catch (InterruptedException e) { - e.printStackTrace(); - } + this.loaderBlockingQueue.add(loader); } public void loadImage() {