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; } }