Skip to content

Commit

Permalink
error message more friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
kitmanzheng committed Dec 25, 2018
1 parent 1f24881 commit 7e85fbf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Binary file modified dep/cos_migrate_tool-1.0-jar-with-dependencies.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public TaskExecutor(MigrateType migrateType, CommonConfig config) {
if (config.getEndpointSuffix() != null) {
clientConfig.setEndPointSuffix(config.getEndpointSuffix());
}
clientConfig.setUserAgent("cos-migrate-tool-v1.0");
clientConfig.setUserAgent("cos-migrate-tool-v1.2.5");

if (!config.getProxyHost().isEmpty() && config.getProxyPort() > 0) {
clientConfig.setHttpProxyIp(config.getProxyHost());
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/com/qcloud/cos_migrate_tool/utils/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private Downloader() {
this.idleConnectionMonitor.start();
}

public HeadAttr headFile(String url, boolean qiniuDownLoadFlag) {
public HeadAttr headFile(String url, boolean qiniuDownLoadFlag) throws Exception {

int retry = 0;
int maxRetryCount = 5;
Expand Down Expand Up @@ -95,8 +95,16 @@ public HeadAttr headFile(String url, boolean qiniuDownLoadFlag) {
httpHead.setHeader("Connection", "Keep-Alive");
httpHead.setHeader("User-Agent", "cos-migrate-tool");

HttpResponse httpResponse = null;
try {
HttpResponse httpResponse = httpClient.execute(httpHead);
httpResponse = httpClient.execute(httpHead);
} catch (Exception e) {
log.error("head file attr fail, url: {}, retry: {}/{}, exception: {}", url, retry,
maxRetryCount, e.toString());
httpHead.abort();
++retry;
}

int http_statuscode = httpResponse.getStatusLine().getStatusCode();
if (http_statuscode < 200 || http_statuscode > 299) {
String errMsg = String.format(
Expand Down Expand Up @@ -146,14 +154,9 @@ public HeadAttr headFile(String url, boolean qiniuDownLoadFlag) {
}

return headAttr;
} catch (Exception e) {
log.error("head file attr fail, url: {}, retry: {}/{}, exception: {}", url, retry,
maxRetryCount, e.toString());
httpHead.abort();
++retry;
}
}
return null;

}

private void showDownloadProgress(String url, long byteTotal, long byteDownloadSofar) {
Expand Down

0 comments on commit 7e85fbf

Please sign in to comment.