Skip to content

Commit 96bebe9

Browse files
author
huangliling
committed
feat: LCObject: saveEventually retries only if LCException httpStatus is 0, 429, 499, or >= 500
1 parent 64820c0 commit 96bebe9

File tree

6 files changed

+29
-4
lines changed

6 files changed

+29
-4
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ Following is change logs for recently release versions, you can refer to [releas
55
> Warning:
66
> DONOT upgrade java-websocket to 1.15.0(or above), bcz it doesn't work on Android 5.1 or earlier version.
77
8+
## 8.2.28 release
9+
10+
#### Break changes
11+
- None
12+
13+
#### New features
14+
- LCObject: saveEventually retries only if LCException httpStatus is 0, 429, 499, or >= 500
15+
16+
#### Optimization and fixed bugs
17+
- None
18+
819
## 8.2.27 release
920

1021
#### Break changes

HOW-TO-PUBLISH.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ signing.keyId=
4848
signing.password=
4949
signing.secretKeyRingFile=
5050
```
51+
增加环境变量
52+
```
53+
export GPG_PASSPHRASE={signing.password}
54+
```
5155
2. 修改 root directory 下的 `CHANGELOG.md` 文件,增加新版本说明。
5256
3. 修改 android-sdk 目录下的 build.gradle 文件,将 `sdkVersion = "8.2.19"` 改为要发布的新版本(修改 Android SDK 依赖的基础 SDK 版本号)。
5357
4. 修改 android-sdk 目录下的 gradle.properties 文件,将 `VERSION_NAME=8.2.19` 改为要发布的新版本(修改 Android SDK 自己的版本号)。

android-sdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ allprojects {
3232
}
3333

3434
ext {
35-
sdkVersion = "8.2.23"
35+
sdkVersion = "8.2.28"
3636
supportLibVersion = "26.1.0"
3737
converterVersion = "2.1.0"
3838
rxandroidVersion = "2.1.1"

android-sdk/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ org.gradle.jvmargs=-Xmx1536m
1515
# This option should only be used with decoupled projects. More details, visit
1616
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1717
# org.gradle.parallel=true
18-
VERSION_NAME=8.2.23
18+
VERSION_NAME=8.2.28
1919
VERSION_CODE=2695
2020
GROUP=cn.leancloud
2121

core/src/main/java/cn/leancloud/ArchivedRequests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,16 @@ public void onNext(LCObject LCObject) {
129129

130130
@Override
131131
public void onError(Throwable throwable) {
132-
logger.w("failed to save archived request. cause: ", throwable);
133132
if (throwable instanceof LCException) {
134133
LCException lcException = (LCException) throwable;
135134
int status = lcException.getHttpStatus();
135+
logger.w("failed to save archived request. cause: " + lcException.getMessage() + ", code: " + lcException.getCode() + ", status: " + status);
136136
if (status == 0 || status == 429 || status >= 499) {
137137
return;
138138
}
139139
onNext(null);
140+
} else {
141+
logger.w("failed to save archived request. cause: ", throwable);
140142
}
141143
}
142144

core/src/main/java/cn/leancloud/LCObject.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,15 @@ public void onNext(LCObject LCObject) {
11841184

11851185
@Override
11861186
public void onError(Throwable throwable) {
1187-
// failed, save data to local file first;
1187+
if (throwable instanceof LCException) {
1188+
LCException lcException = (LCException) throwable;
1189+
int status = lcException.getHttpStatus();
1190+
logger.w("failed to save object. cause: " + lcException.getMessage() + ", code: " + lcException.getCode() + ", status: " + status);
1191+
if (status != 0 && status != 429 && status < 499) {
1192+
return;
1193+
}
1194+
}
1195+
// failed, save data to local file and retry later
11881196
add2ArchivedRequest(false);
11891197
}
11901198

0 commit comments

Comments
 (0)