@@ -50,7 +50,7 @@ public RestfulMgrImpl(RetryStrategy retryStrategy) {
50
50
*/
51
51
public <T > T getJsonData (Class <T > clazz , RemoteUrl remoteUrl , int retryTimes , int retrySleepSeconds )
52
52
throws Exception {
53
-
53
+ Exception ex = null ;
54
54
for (URL url : remoteUrl .getUrls ()) {
55
55
56
56
// 可重试的下载
@@ -63,7 +63,7 @@ public <T> T getJsonData(Class<T> clazz, RemoteUrl remoteUrl, int retryTimes, in
63
63
return t ;
64
64
65
65
} catch (Exception e ) {
66
-
66
+ ex = e ;
67
67
try {
68
68
Thread .sleep (1000 );
69
69
} catch (InterruptedException e1 ) {
@@ -72,7 +72,7 @@ public <T> T getJsonData(Class<T> clazz, RemoteUrl remoteUrl, int retryTimes, in
72
72
}
73
73
}
74
74
75
- throw new Exception ("cannot get: " + remoteUrl );
75
+ throw new Exception ("cannot get: " + remoteUrl , ex );
76
76
}
77
77
78
78
/**
@@ -129,8 +129,8 @@ public String downloadFromServer(RemoteUrl remoteUrl, String fileName, String lo
129
129
//
130
130
// 判断是否下载失败
131
131
//
132
-
133
- if (!localFile .exists ()) {
132
+
133
+ if (localFile == null || !localFile .exists ()) {
134
134
throw new Exception ("target file cannot be found! " + fileName );
135
135
}
136
136
@@ -139,12 +139,10 @@ public String downloadFromServer(RemoteUrl remoteUrl, String fileName, String lo
139
139
//
140
140
141
141
// 返回相对路径
142
- if (localFileDir != null ) {
143
- String relativePathString = OsUtil .getRelativePath (localFile , new File (localFileDir ));
144
- if (relativePathString != null ) {
145
- if (new File (relativePathString ).isFile ()) {
146
- return relativePathString ;
147
- }
142
+ String relativePathString = OsUtil .getRelativePath (localFile , new File (localFileDir ));
143
+ if (relativePathString != null ) {
144
+ if (new File (relativePathString ).isFile ()) {
145
+ return relativePathString ;
148
146
}
149
147
}
150
148
@@ -218,7 +216,7 @@ private File transfer2SpecifyDir(File srcFile, String copy2TargetDirPath, String
218
216
*/
219
217
private Object retry4ConfDownload (RemoteUrl remoteUrl , File localTmpFile , int retryTimes , int sleepSeconds )
220
218
throws Exception {
221
-
219
+ Exception ex = null ;
222
220
for (URL url : remoteUrl .getUrls ()) {
223
221
224
222
// 可重试的下载
@@ -229,7 +227,7 @@ private Object retry4ConfDownload(RemoteUrl remoteUrl, File localTmpFile, int re
229
227
return retryStrategy .retry (unreliableImpl , retryTimes , sleepSeconds );
230
228
231
229
} catch (Exception e ) {
232
-
230
+ ex = e ;
233
231
try {
234
232
Thread .sleep (1000 );
235
233
} catch (InterruptedException e1 ) {
@@ -238,7 +236,7 @@ private Object retry4ConfDownload(RemoteUrl remoteUrl, File localTmpFile, int re
238
236
}
239
237
}
240
238
241
- throw new Exception ("download failed." );
239
+ throw new Exception ("download failed." , ex );
242
240
}
243
241
244
242
}
0 commit comments