diff --git a/library/src/androidTest/java/com/qiniu/android/http/dns/SystemDnsTest.java b/library/src/androidTest/java/com/qiniu/android/http/dns/SystemDnsTest.java index f7b5226e..94eebc3a 100644 --- a/library/src/androidTest/java/com/qiniu/android/http/dns/SystemDnsTest.java +++ b/library/src/androidTest/java/com/qiniu/android/http/dns/SystemDnsTest.java @@ -32,7 +32,7 @@ public void testDnsTimeout() { int timeout = 5; SystemDns dns = new SystemDns(timeout); try { - List result = dns.lookup("a.a.a.cn"); + List result = dns.lookup("abc.mock.cn"); assertTrue("testDnsTimeout fail:", result == null || result.size() == 0); } catch (UnknownHostException e) { e.printStackTrace(); diff --git a/library/src/main/java/com/qiniu/android/common/AutoZone.java b/library/src/main/java/com/qiniu/android/common/AutoZone.java index 07205945..0b597b7b 100644 --- a/library/src/main/java/com/qiniu/android/common/AutoZone.java +++ b/library/src/main/java/com/qiniu/android/common/AutoZone.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -132,7 +131,7 @@ public ZonesInfo getZonesInfo(UpToken token) { @Override public void preQuery(final UpToken token, final QueryHandler completeHandler) { - preQuery(null, token, new QueryHandlerV2() { + query(null, token, new QueryHandlerV2() { @Override public void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics metrics, ZonesInfo zonesInfo) { if (completeHandler != null) { @@ -151,7 +150,7 @@ public void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics metri } @Override - public void preQuery(Configuration configuration, UpToken token, QueryHandlerV2 completeHandler) { + public void query(Configuration configuration, UpToken token, QueryHandlerV2 completeHandler) { if (token == null || !token.isValid()) { completeHandler.complete(ResponseInfo.invalidToken("invalid token"), null, null); return; diff --git a/library/src/main/java/com/qiniu/android/common/FixedZone.java b/library/src/main/java/com/qiniu/android/common/FixedZone.java index 653372bf..74cb34a1 100644 --- a/library/src/main/java/com/qiniu/android/common/FixedZone.java +++ b/library/src/main/java/com/qiniu/android/common/FixedZone.java @@ -217,9 +217,9 @@ public void preQuery(UpToken token, QueryHandler completeHandler) { } @Override - public void preQuery(Configuration configuration, UpToken token, QueryHandlerV2 completeHandler) { + public void query(Configuration configuration, UpToken token, QueryHandlerV2 completeHandler) { if (completeHandler != null) { - completeHandler.complete(null, null, zonesInfo); + completeHandler.complete(ResponseInfo.successResponse(), null, zonesInfo); } } } diff --git a/library/src/main/java/com/qiniu/android/common/Zone.java b/library/src/main/java/com/qiniu/android/common/Zone.java index a86fb82a..adbe0a5a 100644 --- a/library/src/main/java/com/qiniu/android/common/Zone.java +++ b/library/src/main/java/com/qiniu/android/common/Zone.java @@ -40,7 +40,7 @@ protected Zone() { * @param token 上传 token * @param completeHandler 预查询结束回调 */ - public abstract void preQuery(Configuration configuration, UpToken token, final QueryHandlerV2 completeHandler); + public abstract void query(Configuration configuration, UpToken token, final QueryHandlerV2 completeHandler); /** * 预查询结束回调 diff --git a/library/src/main/java/com/qiniu/android/http/dns/DnsPrefetcher.java b/library/src/main/java/com/qiniu/android/http/dns/DnsPrefetcher.java index ae08be56..0f0078d3 100644 --- a/library/src/main/java/com/qiniu/android/http/dns/DnsPrefetcher.java +++ b/library/src/main/java/com/qiniu/android/http/dns/DnsPrefetcher.java @@ -455,7 +455,7 @@ private String[] getCurrentZoneHosts(Configuration configuration, Zone currentZo final Wait wait = new Wait(); final ZonesInfo[] zonesInfoArray = {null}; - currentZone.preQuery(configuration, token, new Zone.QueryHandlerV2() { + currentZone.query(configuration, token, new Zone.QueryHandlerV2() { @Override public void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics metrics, ZonesInfo zonesInfo) { zonesInfoArray[0] = zonesInfo; diff --git a/library/src/main/java/com/qiniu/android/http/serverRegion/UploadDomainRegion.java b/library/src/main/java/com/qiniu/android/http/serverRegion/UploadDomainRegion.java index 78c28d1e..65e1d5af 100644 --- a/library/src/main/java/com/qiniu/android/http/serverRegion/UploadDomainRegion.java +++ b/library/src/main/java/com/qiniu/android/http/serverRegion/UploadDomainRegion.java @@ -195,7 +195,7 @@ public IUploadServer getNextServer(UploadRequestState requestState, ResponseInfo boolean accelerate = true; synchronized (this) { if (enableAccelerateUpload && responseInfo.error != null && - responseInfo.error.equals("transfer acceleration is not configured on this bucket")) { + responseInfo.error.contains("transfer acceleration is not configured on this bucket")) { enableAccelerateUpload = false; } accelerate = enableAccelerateUpload; @@ -218,9 +218,7 @@ public IUploadServer getNextServer(UploadRequestState requestState, ResponseInfo !MapUtils.isEmpty(accelerateDomainHashMap)) { hostList.addAll(accelerateDomainHostList); domainInfo.putAll(accelerateDomainHashMap); - } - - if (!ListUtils.isEmpty(domainHostList) && + } else if (!ListUtils.isEmpty(domainHostList) && !MapUtils.isEmpty(domainHashMap)) { hostList = domainHostList; domainInfo = domainHashMap; diff --git a/library/src/main/java/com/qiniu/android/storage/BaseUpload.java b/library/src/main/java/com/qiniu/android/storage/BaseUpload.java index 80d517e9..1a48f251 100644 --- a/library/src/main/java/com/qiniu/android/storage/BaseUpload.java +++ b/library/src/main/java/com/qiniu/android/storage/BaseUpload.java @@ -97,12 +97,12 @@ public void run() { private void innerRun() { metrics.start(); - config.zone.preQuery(config, token, new Zone.QueryHandlerV2() { + config.zone.query(config, token, new Zone.QueryHandlerV2() { @Override public void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics requestMetrics, ZonesInfo zonesInfo) { metrics.setUcQueryMetrics(requestMetrics); - if (zonesInfo != null) { + if (responseInfo != null && responseInfo.isOK() && zonesInfo != null) { if (!setupRegions(zonesInfo)) { completeAction(responseInfo, null); return; @@ -118,7 +118,7 @@ public void complete(ResponseInfo responseInfo, UploadRegionRequestMetrics reque } else { if (responseInfo == null) { // responseInfo 一定会有值 - responseInfo = ResponseInfo.errorInfo(ResponseInfo.UnknownError, ""); + responseInfo = ResponseInfo.sdkInteriorError("can't get regions"); } completeAction(responseInfo, responseInfo.response); }