Skip to content

Commit 7c72eec

Browse files
author
JemyCheung
committed
buildfromjson func
1 parent db92471 commit 7c72eec

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

library/src/main/java/com/qiniu/android/common/AutoZone.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ boolean preQueryIndex(final ZoneIndex index) {
125125
} else {
126126
try {
127127
ResponseInfo responseInfo = getZoneJsonSync(index);
128+
if (responseInfo.response == null)
129+
return false;
128130
ZoneInfo info2 = ZoneInfo.buildFromJson(responseInfo.response);
129131
zones.put(index, info2);
130132
success = true;

library/src/main/java/com/qiniu/android/common/ZoneInfo.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public ZoneInfo(int ttl, List<String> upDomainsList, Map<String, Long> upDomains
2828
this.upDomainsMap = upDomainsMap;
2929
}
3030

31+
/**
32+
*
33+
* @param obj Not allowed to be null
34+
* @return
35+
* @throws JSONException
36+
*/
3137
public static ZoneInfo buildFromJson(JSONObject obj) throws JSONException {
3238
int ttl = obj.getInt("ttl");
3339
List<String> domainsList = new ArrayList<>();

library/src/main/java/com/qiniu/android/http/DnsPrefetcher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ ZoneInfo preQueryIndex(DnsPrefetcher.ZoneIndex index) {
202202
ZoneInfo info = null;
203203
try {
204204
ResponseInfo responseInfo = getZoneJsonSync(index);
205+
if (responseInfo.response == null)
206+
return null;
205207
info = ZoneInfo.buildFromJson(responseInfo.response);
206208
} catch (JSONException e) {
207209
e.printStackTrace();

0 commit comments

Comments
 (0)