diff --git a/CHANGELOG.md b/CHANGELOG.md index fc41238e..b543833e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ #Changelog +## 8.4.4 (2022-06-02) +* 处理 Dns 预解析内存问题 -## 8.4.3 (2022-5-18) +## 8.4.3 (2022-05-18) * 修复:解决使用分片上传 v1 偶现上传异常:在多个区域域名之间进行上传重试的场景下空指针异常 * 补充了上传 response status code 注释,详情 [code 注释说明](https://github.com/qiniu/android-sdk/blob/master/library/src/main/java/com/qiniu/android/http/ResponseInfo.java) diff --git a/README.md b/README.md index 37630e32..6cc8ed69 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ https://github.com/qiniudemo/qiniu-lab-android | 7.0.7 | Android 2.2+ | android-async-http 1.4.8 | ### 注意 -* 推荐使用最新版:8.4.3 +* 推荐使用最新版:8.4.4 * 7.6.2 ~ 8.3.2 AndroidNetwork.getMobileDbm()可以获取手机信号强度,需要如下权限(API>=18时生效) ``` diff --git a/library/build.gradle b/library/build.gradle index c8fdb533..b7cf4061 100755 --- a/library/build.gradle +++ b/library/build.gradle @@ -54,7 +54,7 @@ dependencies { implementation 'com.squareup.okhttp3:okhttp:4.9.1' // implementation 'com.squareup.okhttp3:okhttp:3.12.+' - implementation 'com.qiniu:happy-dns:1.0.0' + implementation 'com.qiniu:happy-dns:1.0.1' // for javax.annotation.Nullable use in custom MultipartBody and Headers implements. // implementation 'com.google.code.findbugs:jsr305:3.0.2' implementation 'org.conscrypt:conscrypt-android:2.2.1' diff --git a/library/src/main/java/com/qiniu/android/common/Constants.java b/library/src/main/java/com/qiniu/android/common/Constants.java index 398aae48..61542ee8 100644 --- a/library/src/main/java/com/qiniu/android/common/Constants.java +++ b/library/src/main/java/com/qiniu/android/common/Constants.java @@ -3,7 +3,7 @@ public final class Constants { - public static final String VERSION = "8.4.3"; + public static final String VERSION = "8.4.4"; public static final String UTF_8 = "utf-8"; } diff --git a/library/src/main/java/com/qiniu/android/http/dns/BaseDns.java b/library/src/main/java/com/qiniu/android/http/dns/BaseDns.java new file mode 100644 index 00000000..31c1f142 --- /dev/null +++ b/library/src/main/java/com/qiniu/android/http/dns/BaseDns.java @@ -0,0 +1,12 @@ +package com.qiniu.android.http.dns; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +class BaseDns { + int timeout = 10; + static final ExecutorService executor = new ThreadPoolExecutor(0, 4, + 60L, TimeUnit.SECONDS, new LinkedBlockingQueue()); +} diff --git a/library/src/main/java/com/qiniu/android/http/dns/HttpDns.java b/library/src/main/java/com/qiniu/android/http/dns/HttpDns.java index 495d3a70..a16de94f 100644 --- a/library/src/main/java/com/qiniu/android/http/dns/HttpDns.java +++ b/library/src/main/java/com/qiniu/android/http/dns/HttpDns.java @@ -10,8 +10,12 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; -public class HttpDns implements Dns { +public class HttpDns extends BaseDns implements Dns { private IResolver httpIpv4Resolver; private IResolver httpIpv6Resolver; @@ -19,12 +23,12 @@ public class HttpDns implements Dns { public HttpDns(int timeout) { String[] dohIpv4Servers = GlobalConfiguration.getInstance().getDohIpv4Servers(); if (dohIpv4Servers != null && dohIpv4Servers.length > 0) { - httpIpv4Resolver = new DohResolver(dohIpv4Servers, Record.TYPE_A, timeout); + httpIpv4Resolver = new DohResolver(dohIpv4Servers, Record.TYPE_A, timeout, executor); } String[] dohIpv6Servers = GlobalConfiguration.getInstance().getDohIpv6Servers(); if (dohIpv6Servers != null && dohIpv6Servers.length > 0) { - httpIpv6Resolver = new DohResolver(dohIpv6Servers, Record.TYPE_A, timeout); + httpIpv6Resolver = new DohResolver(dohIpv6Servers, Record.TYPE_A, timeout, executor); } } diff --git a/library/src/main/java/com/qiniu/android/http/dns/SystemDns.java b/library/src/main/java/com/qiniu/android/http/dns/SystemDns.java index e6037ae6..a89d0b29 100644 --- a/library/src/main/java/com/qiniu/android/http/dns/SystemDns.java +++ b/library/src/main/java/com/qiniu/android/http/dns/SystemDns.java @@ -19,11 +19,7 @@ /** * Created by yangsen on 2020/5/28 */ -public class SystemDns implements Dns { - - private int timeout = 10; - private static final ExecutorService executor = new ThreadPoolExecutor(1, 3, - 60L, TimeUnit.SECONDS, new LinkedBlockingQueue()); +public class SystemDns extends BaseDns implements Dns { public SystemDns() { } diff --git a/library/src/main/java/com/qiniu/android/http/dns/UdpDns.java b/library/src/main/java/com/qiniu/android/http/dns/UdpDns.java index 845776e2..48d7ca0e 100644 --- a/library/src/main/java/com/qiniu/android/http/dns/UdpDns.java +++ b/library/src/main/java/com/qiniu/android/http/dns/UdpDns.java @@ -10,20 +10,24 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; -public class UdpDns implements Dns { +public class UdpDns extends BaseDns implements Dns { private IResolver udpIpv4Resolver; private IResolver udpIpv6Resolver; public UdpDns(int timeout) { String[] udpIpv4Servers = GlobalConfiguration.getInstance().getUdpDnsIpv4Servers(); if (udpIpv4Servers != null && udpIpv4Servers.length > 0) { - udpIpv4Resolver = new DnsUdpResolver(udpIpv4Servers, Record.TYPE_A, timeout); + udpIpv4Resolver = new DnsUdpResolver(udpIpv4Servers, Record.TYPE_A, timeout, executor); } String[] udpIpv6Servers = GlobalConfiguration.getInstance().getUdpDnsIpv6Servers(); if (udpIpv6Servers != null && udpIpv6Servers.length > 0) { - udpIpv6Resolver = new DnsUdpResolver(udpIpv6Servers, Record.TYPE_A, timeout); + udpIpv6Resolver = new DnsUdpResolver(udpIpv6Servers, Record.TYPE_A, timeout, executor); } }