Skip to content

Commit a0f6b1f

Browse files
authored
Merge pull request #265 from sxci/up_log_3
上传日志收集使用v3版本;happy-dns、okhttp 升级
2 parents d60e654 + 27ef520 commit a0f6b1f

File tree

15 files changed

+164
-132
lines changed

15 files changed

+164
-132
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
#Changelog
22

3+
4+
## 7.3.7 (2017-07-06)
5+
* 上传日志收集使用 v3 版本
6+
* happy-dns 到 0.2.13 ,其修复了潜在的并发调用问题
7+
* okhttp 到 3.8.1
8+
9+
## 7.3.6 (2017-06-08)
10+
11+
### 修正
12+
* AutoZone 查询时,部分情况不进入回调
13+
314
## 7.3.3 (2017-01-18)
415

516
### 增加

library/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ android {
3636
}
3737

3838
dependencies {
39-
compile 'com.squareup.okhttp3:okhttp:3.2.0'
40-
compile 'com.qiniu:happy-dns:0.2.7'
39+
compile 'com.squareup.okhttp3:okhttp:3.8.1'
40+
compile 'com.qiniu:happy-dns:0.2.13'
4141
compile fileTree(include: ['*.jar'], dir: 'libs')
4242
}
4343

4444
task releaseJar(type: Jar, dependsOn: 'build') {
4545
//指定生成的jar名
4646
baseName 'qiniu-android-sdk-' + version
4747
//从哪里打包class文件
48-
from('build/intermediates/classes/release/com/qiniu/android/dns/')
48+
// from('build/intermediates/classes/release/com/qiniu/android/dns/')
4949
//打包到jar后的目录结构
50-
into('com/qiniu/android/dns/')
50+
// into('com/qiniu/android/dns/')
5151
//去掉不需要打包的目录和文件
5252
exclude('test/', 'BuildConfig.class', 'R.class')
5353
//去掉R$开头的文件

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ private static String getRecordFileSizes() {
106106
}
107107

108108
public static File getRecordFile() {
109-
String recordFileName = "_qiniu_record_file_hu3z9lo7anx03";
109+
String recordFileName = "_qiniu_record_file_hs5z9lo7anx03";
110110
File recordFile = new File(Config.recordDir, recordFileName);
111111
return recordFile;
112112
}
113113

114114
public static void recordFileTest() {
115-
// showRecordInfo();
115+
showRecordInfo();
116116
recordFile();
117117
ACollectUploadInfoUpTest.recordFileTest();
118118
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ private static String getRecordFileSizes() {
106106
}
107107

108108
public static File getRecordFile() {
109-
String recordFileName = "_qiniu_record_file_upm6xola4sk3";
109+
String recordFileName = "_qiniu_record_file_hs5z9lo7anx03";
110110
File recordFile = new File(Config.recordDir, recordFileName);
111111
return recordFile;
112112
}
113113

114114
public static void recordFileTest() {
115-
// showRecordInfo();
115+
showRecordInfo();
116116
recordFile();
117117
}
118118

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ protected void setUp() throws Exception {
4747
@SmallTest
4848
public void testPost1() throws Throwable {
4949
httpManager.asyncPost("http://www.baidu.com",
50-
"hello".getBytes(), null, UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
50+
"hello".getBytes(), null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
51+
null, new CompletionHandler() {
5152
@Override
5253
public void complete(ResponseInfo rinfo, JSONObject response) {
5354
Assert.assertNotNull(rinfo);
@@ -69,7 +70,8 @@ public void complete(ResponseInfo rinfo, JSONObject response) {
6970
public void testPost2() throws Throwable {
7071

7172
httpManager.asyncPost("http://up.qiniu.com", "hello".getBytes(), null,
72-
UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
73+
UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
74+
null, new CompletionHandler() {
7375
@Override
7476
public void complete(ResponseInfo rinfo, JSONObject response) {
7577
Log.d("qiniutest", rinfo.toString());
@@ -91,7 +93,8 @@ public void testPost3() throws Throwable {
9193
runTestOnUiThread(new Runnable() { // THIS IS THE KEY TO SUCCESS
9294
public void run() {
9395
httpManager.asyncPost("http://httpbin.org/status/500", "hello".getBytes(),
94-
null, UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
96+
null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
97+
null, new CompletionHandler() {
9598
@Override
9699
public void complete(ResponseInfo rinfo, JSONObject response) {
97100
Log.d("qiniutest", rinfo.toString());
@@ -117,7 +120,8 @@ public void testPost4() throws Throwable {
117120
public void run() {
118121
httpManager.asyncPost("http://httpbin.org/status/418",
119122
"hello".getBytes(),
120-
null, UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
123+
null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
124+
null, new CompletionHandler() {
121125
@Override
122126
public void complete(ResponseInfo rinfo, JSONObject response) {
123127
Log.d("qiniutest", rinfo.toString());
@@ -141,7 +145,8 @@ public void complete(ResponseInfo rinfo, JSONObject response) {
141145
public void testPostNoDomain() throws Throwable {
142146

143147
httpManager.asyncPost("http://no-domain.qiniu.com", "hello".getBytes(),
144-
null, UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
148+
null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
149+
null, new CompletionHandler() {
145150
@Override
146151
public void complete(ResponseInfo rinfo, JSONObject response) {
147152
Log.d("qiniutest", rinfo.toString());
@@ -186,7 +191,8 @@ public void complete(ResponseInfo rinfo, JSONObject response) {
186191
public void testPostIP() throws Throwable {
187192
StringMap x = new StringMap().put("Host", "up.qiniu.com");
188193
httpManager.asyncPost("http://183.131.7.18", "hello".getBytes(),
189-
x, UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
194+
x, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
195+
null, new CompletionHandler() {
190196
@Override
191197
public void complete(ResponseInfo rinfo, JSONObject response) {
192198
Log.d("qiniutest", rinfo.toString());
@@ -210,7 +216,8 @@ public void testProxy() throws Throwable {
210216
ProxyConfiguration p = new ProxyConfiguration("115.231.183.168", 80);
211217
Client c = new Client(p, 10, 30, null, null);
212218
c.asyncPost("http://upproxy1.qiniu.com", "hello".getBytes(),
213-
x, UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
219+
x, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
220+
null, new CompletionHandler() {
214221
@Override
215222
public void complete(ResponseInfo rinfo, JSONObject response) {
216223
Log.d("qiniutest", rinfo.toString());

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected void setUp() throws Exception {
4343
@SmallTest
4444
public void testPost1() throws Throwable {
4545
httpManager.asyncPost("https://www.baidu.com/", "hello".getBytes(), null,
46-
UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
46+
UpToken.parse(TestConfig.token_z0), "hello".getBytes().length, null, new CompletionHandler() {
4747
@Override
4848
public void complete(ResponseInfo rinfo, JSONObject response) {
4949
Log.d("qiniutest", rinfo.toString());
@@ -64,7 +64,8 @@ public void complete(ResponseInfo rinfo, JSONObject response) {
6464
@SmallTest
6565
public void testPost2() throws Throwable {
6666
httpManager.asyncPost("https://static-fw.qbox.me/public/v28812/add-on/ga/analytics.js",
67-
"hello".getBytes(), null, UpToken.parse(TestConfig.token_z0), null, new CompletionHandler() {
67+
"hello".getBytes(), null, UpToken.parse(TestConfig.token_z0), "hello".getBytes().length,
68+
null, new CompletionHandler() {
6869
@Override
6970
public void complete(ResponseInfo rinfo, JSONObject response) {
7071
Log.d("qiniutest", rinfo.toString());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private void template2(int size) throws Throwable {
7878
String[] s = new String[]{"up.qbox.me"};
7979
Zone z = new FixedZone(s);
8080
Configuration c = new Configuration.Builder()
81-
.zone(z)
81+
.zone(z).useHttps(true)
8282
.build();
8383
UploadManager uploadManager2 = new UploadManager(c);
8484
uploadManager2.put(f, expectKey, TestConfig.token_z0, new UpCompletionHandler() {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ public class Config {
7373
/**
7474
* 上传信息收集文件的地址
7575
*/
76-
public final static String serverURL = "https://uplog.qbox.me/log";
76+
public final static String serverURL = "https://uplog.qbox.me/log/3";
7777

78-
public final static String serverURL2 = "https://uplog.qbox.me/log/2";
7978

8079
/**
8180
* 当网络切换到 wifi 下,切换到此设置

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

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,14 @@ public class UploadInfoCollector {
3636
private long lastUpload;// milliseconds
3737

3838
private static UploadInfoCollector httpCollector;
39-
private static UploadInfoCollector uploadCollector;
4039

4140
private static UploadInfoCollector getHttpCollector() {
4241
if (httpCollector == null) {
43-
httpCollector = new UploadInfoCollector("_qiniu_record_file_hu3z9lo7anx03", Config.serverURL);
42+
httpCollector = new UploadInfoCollector("_qiniu_record_file_hs5z9lo7anx03", Config.serverURL);
4443
}
4544
return httpCollector;
4645
}
4746

48-
private static UploadInfoCollector getUploadCollector() {
49-
if (uploadCollector == null) {
50-
uploadCollector = new UploadInfoCollector("_qiniu_record_file_upm6xola4sk3", Config.serverURL2);
51-
}
52-
return uploadCollector;
53-
}
54-
5547

5648
private UploadInfoCollector(String recordFileName, String serverURL) {
5749
this.recordFileName = recordFileName;
@@ -84,13 +76,6 @@ public static void clean() {
8476
e.printStackTrace();
8577
}
8678
httpCollector = null;
87-
try {
88-
getUploadCollector().clean0();
89-
} catch (Exception e) {
90-
e.printStackTrace();
91-
}
92-
uploadCollector = null;
93-
9479
}
9580

9681

@@ -119,11 +104,6 @@ public static void reset() {
119104
} catch (Exception e) {
120105
e.printStackTrace();
121106
}
122-
try {
123-
getUploadCollector().reset0();
124-
} catch (Exception e) {
125-
e.printStackTrace();
126-
}
127107
}
128108

129109
private void reset0() throws IOException {
@@ -173,13 +153,7 @@ public static void handleHttp(final UpToken upToken, final RecordMsg record) {
173153
}
174154

175155
public static void handleUpload(final UpToken upToken, final RecordMsg record) {
176-
try {
177-
if (Config.isRecord) {
178-
getUploadCollector().handle0(upToken, record);
179-
}
180-
} catch (Throwable t) {
181-
// do nothing
182-
}
156+
handleHttp(upToken, record);
183157
}
184158

185159
private void handle0(final UpToken upToken, final RecordMsg record) {

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.3.5";
5+
public static final String VERSION = "7.3.7";
66

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

0 commit comments

Comments
 (0)