Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
Catch some json exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen committed Nov 13, 2020
1 parent 1baf564 commit e1c7dff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
DOCKER_TOKEN: ${{ secrets.DOCKER }}
run: |
docker login docker.pkg.github.com --username LinuxSuRen --password ${DOCKER_TOKEN}
docker build . -t docker.pkg.github.com/jenkins-zh/mirror-adapter/mirror-adapter:0.0.5
docker push docker.pkg.github.com/jenkins-zh/mirror-adapter/mirror-adapter:0.0.5
docker build . -t docker.pkg.github.com/jenkins-zh/mirror-adapter/mirror-adapter:0.0.6
docker push docker.pkg.github.com/jenkins-zh/mirror-adapter/mirror-adapter:0.0.6
6 changes: 5 additions & 1 deletion src/main/java/cn/jenkins/zh/updatecenter/MirrorAdapter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.jenkins.zh.updatecenter;

import net.sf.json.JSONException;
import net.sf.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.kohsuke.args4j.ClassParser;
Expand Down Expand Up @@ -94,9 +95,9 @@ private int signUpdateCenterJSON() throws IOException, GeneralSecurityException,
return -2;
}

ByteArrayOutputStream data = new ByteArrayOutputStream();
try(InputStream input = new FileInputStream(officialJSON);
FileOutputStream out = new FileOutputStream(mirrorJSON);) {
ByteArrayOutputStream data = new ByteArrayOutputStream();
IOUtils.copy(input, data);

String jsonStr = data.toString("UTF-8");
Expand Down Expand Up @@ -124,6 +125,9 @@ private int signUpdateCenterJSON() throws IOException, GeneralSecurityException,

JSONObject result = signer.sign(json);
out.write((jsonHeader + result.toString() + jsonFooter).getBytes());
} catch (JSONException e) {
e.printStackTrace();
System.err.println("Error happened when parse json file from '" + officialJSON + "', data is: " + data.toString());
}
return 0;
}
Expand Down

0 comments on commit e1c7dff

Please sign in to comment.