Skip to content

Commit

Permalink
Fix #19 Exception on Intellij IU-163.12024.16
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Feb 14, 2017
1 parent 69f4173 commit 6bf8e36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<id>org.zkoss.zkidea</id>
<name>ZK</name>
<version>0.1.8</version>
<version>0.1.9</version>
<vendor email="info@zkoss.org" url="http://www.zkoss.org">ZK Framework</vendor>
<depends>org.jetbrains.idea.maven</depends>

Expand All @@ -12,6 +12,11 @@
]]></description>

<change-notes><![CDATA[
<p>0.1.9</p>
<ul>
<li> [bug] #19 - Exception on Intellij IU-163.12024.16 </li>
</ul>
<br>
<p>0.1.8</p>
<ul>
<li> [bug] #14 - Worker exited due to exception </li>
Expand Down
12 changes: 10 additions & 2 deletions src/org/zkoss/zkidea/project/ZKProjectsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ public void run() {
LOG.info("Downloading latest zul file: " + ZulSchemaProvider.ZUL_PROJECT_SCHEMA_URL);

File fileTmp = new File(fileSrc.getAbsolutePath() + ".tmp");
FileUtil.writeToFile(fileTmp, download(new URL(ZulSchemaProvider.ZUL_PROJECT_SCHEMA_URL)));
byte[] download = download(
new URL(ZulSchemaProvider.ZUL_PROJECT_SCHEMA_URL));
if (download != null && download.length == 0)
return; // try next time.
FileUtil.writeToFile(fileTmp, download);
// HttpRequests.request(ZulSchemaProvider.ZUL_PROJECT_SCHEMA_URL).saveToFile(fileTmp, ProgressManager.getGlobalProgressIndicator());
double origin = getSchemaVersion(fileSrc);
double newone = getSchemaVersion(fileTmp);
Expand All @@ -154,6 +158,7 @@ public void run() {
private byte[] download(URL url) throws IOException {
URLConnection uc = url.openConnection();
int len = uc.getContentLength();
if (len < 0) return new byte[0];
InputStream is = new BufferedInputStream(uc.getInputStream());
try {
byte[] data = new byte[len];
Expand Down Expand Up @@ -189,7 +194,10 @@ private void updateMavenArchetype() {

File fileTmp = new File(fileSrc.getAbsolutePath() + ".tmp");

FileUtil.writeToFile(fileTmp, download(new URL(ZKMavenArchetypesProvider.MAVEN_ARCHETYPE_URL)));
byte[] download = download(new URL(ZKMavenArchetypesProvider.MAVEN_ARCHETYPE_URL));
if (download != null && download.length == 0)
return; // try next time.
FileUtil.writeToFile(fileTmp, download);
// HttpRequests.request(ZKMavenArchetypesProvider.MAVEN_ARCHETYPE_URL).saveToFile(fileTmp, ProgressManager.getGlobalProgressIndicator());

if (fileTmp.length() > fileSrc.length()) {
Expand Down

0 comments on commit 6bf8e36

Please sign in to comment.