Skip to content

Commit 7e85fbf

Browse files
committed
error message more friendly
1 parent 1f24881 commit 7e85fbf

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed
7 Bytes
Binary file not shown.

src/main/java/com/qcloud/cos_migrate_tool/task/TaskExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public TaskExecutor(MigrateType migrateType, CommonConfig config) {
5858
if (config.getEndpointSuffix() != null) {
5959
clientConfig.setEndPointSuffix(config.getEndpointSuffix());
6060
}
61-
clientConfig.setUserAgent("cos-migrate-tool-v1.0");
61+
clientConfig.setUserAgent("cos-migrate-tool-v1.2.5");
6262

6363
if (!config.getProxyHost().isEmpty() && config.getProxyPort() > 0) {
6464
clientConfig.setHttpProxyIp(config.getProxyHost());

src/main/java/com/qcloud/cos_migrate_tool/utils/Downloader.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private Downloader() {
5454
this.idleConnectionMonitor.start();
5555
}
5656

57-
public HeadAttr headFile(String url, boolean qiniuDownLoadFlag) {
57+
public HeadAttr headFile(String url, boolean qiniuDownLoadFlag) throws Exception {
5858

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

98+
HttpResponse httpResponse = null;
9899
try {
99-
HttpResponse httpResponse = httpClient.execute(httpHead);
100+
httpResponse = httpClient.execute(httpHead);
101+
} catch (Exception e) {
102+
log.error("head file attr fail, url: {}, retry: {}/{}, exception: {}", url, retry,
103+
maxRetryCount, e.toString());
104+
httpHead.abort();
105+
++retry;
106+
}
107+
100108
int http_statuscode = httpResponse.getStatusLine().getStatusCode();
101109
if (http_statuscode < 200 || http_statuscode > 299) {
102110
String errMsg = String.format(
@@ -146,14 +154,9 @@ public HeadAttr headFile(String url, boolean qiniuDownLoadFlag) {
146154
}
147155

148156
return headAttr;
149-
} catch (Exception e) {
150-
log.error("head file attr fail, url: {}, retry: {}/{}, exception: {}", url, retry,
151-
maxRetryCount, e.toString());
152-
httpHead.abort();
153-
++retry;
154-
}
155157
}
156158
return null;
159+
157160
}
158161

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

0 commit comments

Comments
 (0)