From da6bb600f14f92fa74439ff268ac97b0e8a110ad Mon Sep 17 00:00:00 2001 From: pengda Date: Thu, 3 Jun 2021 14:57:07 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-51958=20=E8=BF=9C=E7=A8=8B=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=A3=80=E6=B5=8B=E5=8F=8A=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/VersionCheckUtils.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/VersionCheckUtils.java b/designer-base/src/main/java/com/fr/design/VersionCheckUtils.java index d823ea6d2e..754b8a8b18 100644 --- a/designer-base/src/main/java/com/fr/design/VersionCheckUtils.java +++ b/designer-base/src/main/java/com/fr/design/VersionCheckUtils.java @@ -52,6 +52,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; /** * @author pengda @@ -287,6 +288,7 @@ public class VersionCheckUtils { @Override public void updateProgress(String description, double progress) { } + @Override public void done(PluginTaskResult result) { latch.countDown(); @@ -295,9 +297,9 @@ public class VersionCheckUtils { } } try { - latch.await(); + latch.await(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { - e.printStackTrace(); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } @@ -314,6 +316,7 @@ public class VersionCheckUtils { } syncFailedPlugins.add(plugin); } + CommonIOUtils.deleteFile(new File(SYNCLIB)); return syncFailedPlugins; } @@ -378,7 +381,7 @@ public class VersionCheckUtils { JSONObject differentPlugin; String id; String version; - try { + if (differentPlugins != null) { for (int i = 0; i < differentPlugins.size(); i++) { String url = null; differentPlugin = differentPlugins.getJSONObject(i); @@ -392,11 +395,10 @@ public class VersionCheckUtils { } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - - downloadURL.put(id + "-" + version, url); + if (url != null) { + downloadURL.put(id + "-" + version, url); + } } - } catch (Exception e) { - } return getPluginZipDownloadURL(downloadURL); } @@ -406,6 +408,7 @@ public class VersionCheckUtils { CloseableHttpResponse httpResponse; HttpGet httpGet = new HttpGet(); InputStream in = null; + HashMap downloadURLs = new HashMap<>(); try { for (String idAndVersion : urls.keySet()) { httpClient = HttpToolbox.getHttpClient(urls.get(idAndVersion)); @@ -415,7 +418,7 @@ public class VersionCheckUtils { JSONObject urlJson = new JSONObject(IOUtils.inputStream2String(in)); String downloadURL = urlJson.getString("result"); if (downloadURL != null) { - urls.replace(idAndVersion, urlJson.getString("result")); + downloadURLs.put(idAndVersion,downloadURL); } } } catch (Exception e) { @@ -423,6 +426,6 @@ public class VersionCheckUtils { } finally { CommonIOUtils.close(in); } - return urls; + return downloadURLs; } }