Skip to content

Commit 06f33b9

Browse files
author
liuyj
committed
[fix]
1. 修改sdk设置长连接有效期单位
1 parent a503c05 commit 06f33b9

6 files changed

Lines changed: 58 additions & 9 deletions

File tree

CHANGES.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Release Notes
2+
3+
## 1.0.0.5
4+
### Fix
5+
修复长连接单位错误问题 由分钟改为秒
6+
7+
## 1.0.0.4
8+
### Features
9+
支持设置长连接有效期
10+
11+
## 1.0.0.3
12+
### Features
13+
1. ios支持自定义参数
14+
15+
### Fix
16+
1. 修复jdk11 json反序列化报错问题: ParameterizedTypeImpl 类找不到
17+
2. 修复jdk1.6 https证书错误问题
18+
3. 服务端返回500支持重试
19+
4. 修复首次鉴权失败后空指针异常
20+
21+
## 1.0.0.2
22+
### Features
23+
1. 支持设置httpclient最大连接数,解决并发大时获取连接慢问题

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<dependency>
2323
<groupId>com.getui.push</groupId>
2424
<artifactId>restful-sdk</artifactId>
25-
<version>1.0.0.4</version>
25+
<version>1.0.0.5</version>
2626
</dependency>
2727
```
2828

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.getui.push</groupId>
88
<artifactId>restful-sdk</artifactId>
99
<packaging>jar</packaging>
10-
<version>1.0.0.4</version>
10+
<version>1.0.0.5</version>
1111
<url>https://github.com/GetuiLaboratory/getui-pushapi-java-client-v2</url>
1212
<name>Getui Push API Java Client</name>
1313
<description>Getui's officially supported Java client library for accessing Getui APIs.</description>

src/main/java/com/getui/push/v2/sdk/GtApiConfiguration.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ public class GtApiConfiguration {
6666
*/
6767
private int maxHttpTryTime = 1;
6868
/**
69-
* 保持长连接的时长,默认10分钟
69+
* 保持长连接的时长,默认10s,最大{@link #MAX_KEEP_ALIVE_SECONDS}
7070
*/
71-
private long keepAliveMinutes = 10;
71+
private long keepAliveSeconds = 10;
72+
final long MAX_KEEP_ALIVE_SECONDS = 30;
7273

7374
/**
7475
* http请求时是否需要信任https
@@ -187,12 +188,37 @@ public void setMaxHttpTryTime(int maxHttpTryTime) {
187188
this.maxHttpTryTime = maxHttpTryTime;
188189
}
189190

191+
public long getKeepAliveSeconds() {
192+
return keepAliveSeconds;
193+
}
194+
195+
public void setKeepAliveSeconds(long keepAliveSeconds) {
196+
if (keepAliveSeconds > MAX_KEEP_ALIVE_SECONDS) {
197+
this.keepAliveSeconds = MAX_KEEP_ALIVE_SECONDS;
198+
} else {
199+
this.keepAliveSeconds = keepAliveSeconds;
200+
}
201+
}
202+
203+
/**
204+
* replaced by <code>getKeepAliveSeconds()</code>.
205+
* will be removed in the next version
206+
*
207+
* @return
208+
*/
209+
@Deprecated
190210
public long getKeepAliveMinutes() {
191-
return keepAliveMinutes;
211+
return 0;
192212
}
193213

214+
/**
215+
* replaced by <code>setKeepAliveSeconds()</code>.
216+
* will be removed in the next version
217+
*
218+
* @param keepAliveMinutes
219+
*/
220+
@Deprecated
194221
public void setKeepAliveMinutes(long keepAliveMinutes) {
195-
this.keepAliveMinutes = keepAliveMinutes;
196222
}
197223

198224
public GtHttpProxyConfig getProxyConfig() {

src/main/java/com/getui/push/v2/sdk/common/http/GtHttpClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class GtHttpClient {
3636
private int maxHttpTryTime;
3737
CloseableHttpClient httpclient;
3838

39-
public GtHttpClient(int connectTimeout, int soTimeout, int maxHttpTryTime, long keepAliveMinutes, GtHttpProxyConfig proxyConfig, boolean trustSSL) {
39+
public GtHttpClient(int connectTimeout, int soTimeout, int maxHttpTryTime, long keepAliveSeconds, GtHttpProxyConfig proxyConfig, boolean trustSSL) {
4040
if (connectTimeout <= 0) {
4141
throw new IllegalArgumentException("connectTimeout must be > 0.");
4242
}
@@ -65,7 +65,7 @@ public GtHttpClient(int connectTimeout, int soTimeout, int maxHttpTryTime, long
6565
.setMaxRedirects(0)
6666
.build();
6767
builder.setDefaultRequestConfig(config)
68-
.setConnectionTimeToLive(keepAliveMinutes, TimeUnit.MINUTES)
68+
.setConnectionTimeToLive(keepAliveSeconds, TimeUnit.SECONDS)
6969
.useSystemProperties();
7070
this.httpclient = builder.build();
7171
}

src/main/java/com/getui/push/v2/sdk/core/client/DefaultApiClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private DefaultApiClient(GtApiConfiguration apiConfiguration, IJson json) {
131131

132132
this.httpManager = new HttpManager(apiConfiguration.getConnectTimeout(),
133133
apiConfiguration.getSoTimeout(), apiConfiguration.getMaxHttpTryTime(),
134-
apiConfiguration.getKeepAliveMinutes(), apiConfiguration.getProxyConfig(),
134+
apiConfiguration.getKeepAliveSeconds(), apiConfiguration.getProxyConfig(),
135135
apiConfiguration.isTrustSSL());
136136

137137
this.hostManager = new HostManager(apiConfiguration, this.httpManager);

0 commit comments

Comments
 (0)