Skip to content

Commit 9232709

Browse files
authored
Merge pull request #414 from YangSen-qn/sdk_v7_dns_create_file_error
version 7: dns create file error
2 parents 15aaf24 + 4ec68cf commit 9232709

File tree

8 files changed

+25
-13
lines changed

8 files changed

+25
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#Changelog
2+
# 7.6.7
3+
* 修复创建dns缓存文件失败问题
4+
25
# 7.6.6
36
* 修复部分空指针异常
47

Qiniu_Android.iml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id="Qiniu_Android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id="QiNiu_Android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="java-gradle" name="Java-Gradle">
55
<configuration>
@@ -13,7 +13,7 @@
1313
<content url="file://$MODULE_DIR$">
1414
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
1515
</content>
16-
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
16+
<orderEntry type="inheritedJdk" />
1717
<orderEntry type="sourceFolder" forTests="false" />
1818
</component>
1919
</module>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ https://github.com/qiniudemo/qiniu-lab-android
2525
| 7.0.7 | Android 2.2+ | android-async-http 1.4.8 |
2626

2727
### 注意
28-
* 推荐使用最新版:7.6.6
28+
* 推荐使用最新版:7.6.7
2929
* AndroidNetwork.getMobileDbm()可以获取手机信号强度,需要如下权限(API>=18时生效)
3030
```
3131
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

library/src/androidTest/java/com/qiniu/android/TestConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ public final class TestConfig {
1010
// TODO: 2020-05-09 bad token for testPutBytesWithFixedZoneUseBackupDomains
1111
//华东上传凭证
1212
public static final String bucket_z0 = "sdk-z0";
13-
public static final String token_z0 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:fO65e-s-sRrcNiWkZ3qcrCLM3pM=:eyJzY29wZSI6InNkay16MCIsImRlYWRsaW5lIjoxNTk3MjAyMDYwfQ==";
13+
public static final String token_z0 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:EhEVhvMUxV41FUXANl2YU4UES2I=:eyJzY29wZSI6InNkay16MCIsImRlYWRsaW5lIjoxNjA2NDU5OTg3fQ==";
1414
//华北上传凭证
1515
public static final String bucket_z1 = "sdk-z1";
16-
public static final String token_z1 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:KHpcWxGAAut9zJjGaHEqEbjlf-c=:eyJzY29wZSI6InNkay16MSIsImRlYWRsaW5lIjoxNTk3MjAyMDgzfQ==";
16+
public static final String token_z1 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:yOKL2sqzRSNiOb1bb5OeRonHQfI=:eyJzY29wZSI6InNkay16MSIsImRlYWRsaW5lIjoxNjA2NDYwMDA2fQ==";
1717
//华南上传凭证
1818
public static final String bucket_z2 = "sdk-z2";
19-
public static final String token_z2 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:yt7nub2-FOkK2zwodXSgxinpboE=:eyJzY29wZSI6InNkay16MiIsImRlYWRsaW5lIjoxNTk3MjAyMTAwfQ==";
19+
public static final String token_z2 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:VVB2X8hQYwGQnkNFUzn26kom1Qc=:eyJzY29wZSI6InNkay16MiIsImRlYWRsaW5lIjoxNjA2NDYwMDIyfQ==";
2020
//北美上传凭证
2121
public static final String bucket_na0 = "sdk-na0";
22-
public static final String token_na0 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:J9AbA4jVl4BtsAFg9XooZaa2Iyk=:eyJzY29wZSI6InNkay1uYTAiLCJkZWFkbGluZSI6MTU5NzIwMjExNX0=";
22+
public static final String token_na0 = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW:b46IRIripBu1p2dV1VVBvqM9au4=:eyJzY29wZSI6InNkay1uYTAiLCJkZWFkbGluZSI6MTYwNjQ2MDAzOH0=";
2323
public static final String ak = "bjtWBQXrcxgo7HWwlC_bgHg81j352_GhgBGZPeOW";
2424

2525

library/src/main/java/com/qiniu/android/collect/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public final class Config {
7878
/**
7979
* dns缓存信息目录
8080
*/
81-
public static String dnscacheDir = Environment.getExternalStorageDirectory() + File.separator + "dnschache" + File.separator;
81+
public static String dnscacheDir = ContextGetter.applicationContext().getCacheDir().getAbsolutePath() + "/dnsCache/";
8282

8383
/**
8484
* preQuery host

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
public final class Constants {
5-
public static final String VERSION = "7.6.6";
5+
public static final String VERSION = "7.6.7";
66

77
public static final String UTF_8 = "utf-8";
88
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,14 @@ public static boolean recoverCache(Configuration config) {
357357
if (data == null)
358358
return true;
359359

360-
DnsCacheInfo cacheInfo = (DnsCacheInfo) StringUtils.toObject(data);
360+
DnsCacheInfo cacheInfo = null;
361+
Object cacheInfoObject = StringUtils.toObject(data);
362+
if (cacheInfoObject instanceof DnsCacheInfo){
363+
cacheInfo = (DnsCacheInfo) StringUtils.toObject(data);
364+
} else {
365+
recorder.del(localIP);
366+
}
367+
361368
if (cacheInfo == null)
362369
return true;
363370

@@ -411,7 +418,8 @@ public static void startPrefetchDns(String token, Configuration config) {
411418
}
412419
if (dnsPrefetcher != null) {
413420
ConcurrentHashMap<String, List<InetAddress>> concurrentHashMap = dnsPrefetcher.getConcurrentHashMap();
414-
byte[] dnscache = StringUtils.toByteArray(concurrentHashMap);
421+
dnsCacheInfo.info = concurrentHashMap;
422+
byte[] dnscache = StringUtils.toByteArray(dnsCacheInfo);
415423
if (dnscache == null)
416424
return;
417425
recorder.set(cacheKey, dnscache);

library/src/main/java/com/qiniu/android/storage/persistent/DnsCacheFile.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ public class DnsCacheFile implements Recorder {
2020
public DnsCacheFile(String directory) throws IOException {
2121
this.directory = directory;
2222
f = new File(directory);
23-
if (f.isDirectory() || !f.exists()) {
23+
24+
if (!f.exists()) {
2425
boolean r = f.mkdirs();
2526
if (!r) {
2627
throw new IOException("mkdir failed");
2728
}
28-
return;
2929
}
30+
3031
if (!f.isDirectory()) {
3132
throw new IOException("does not mkdir");
3233
}

0 commit comments

Comments
 (0)