From de30d7a118764a5c0b835b9ba4aa0c2a27135a49 Mon Sep 17 00:00:00 2001 From: zhutianhao Date: Thu, 27 Aug 2020 18:04:46 +0800 Subject: [PATCH] Update RESTApiFacadeImpl.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 订阅事件接口可以传入事件数组,为什么要用循环调用?使用循环调用会使这些相同类型的事件被订阅到不同的事件处理wrapper对象,导致每个异步api的返回事件都会重复300多次调用这个文件中的handleEvent()。 --- .../src/main/java/org/zstack/core/rest/RESTApiFacadeImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/main/java/org/zstack/core/rest/RESTApiFacadeImpl.java b/core/src/main/java/org/zstack/core/rest/RESTApiFacadeImpl.java index e9d9ead27f3..625e1fb6d8b 100755 --- a/core/src/main/java/org/zstack/core/rest/RESTApiFacadeImpl.java +++ b/core/src/main/java/org/zstack/core/rest/RESTApiFacadeImpl.java @@ -112,9 +112,7 @@ void init() throws ClassNotFoundException, InstantiationException, IllegalAccess } } - for (APIEvent e : boundEvents) { - bus.subscribeEvent(this, e); - } + bus.subscribeEvent(this, boundEvents.toArray(new APIEvent[boundEvents.size()])); } private static int initMaxRestResultLength() {