Skip to content

Commit ecfad5b

Browse files
author
dongfuqiang
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 245c7cc + cf762f5 commit ecfad5b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+519
-680
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ Icon
4848
Network Trash Folder
4949
Temporary Items
5050
.apdisk
51+
/.sonar/
52+
sonar-project.properties

.travis.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
language: java
2-
jdk:
3-
- oraclejdk7
4-
5-
script: "mvn clean package -Dmaven.test.skip=true"
2+
sudo: false
3+
install: true
4+
addons:
5+
sonarqube:
6+
token:
7+
secure: "834110c7191f97ecb226970c46dcaff8e681da5a"
68

9+
jdk:
10+
- oraclejdk8
11+
#script: "mvn clean package -Dmaven.test.skip=true"
12+
13+
script:
14+
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
15+
716
branches:
817
only:
918
- develop
19+
20+
cache:
21+
directories:
22+
- '$HOME/.m2/repository'
23+
- '$HOME/.sonar/cache'
1024

1125
notifications:
1226
email:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Weixin Java Tools 微信公众号/企业号开发Java SDK
22
=====================================
33
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent)
4-
[![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools)
4+
[![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/Wechat-Group/weixin-java-tools)
55

66
### 注意:
77
1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。***
@@ -13,7 +13,7 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK
1313

1414
## 开发交流方式及注意事项:
1515
1. QQ群:343954419(推荐点击按钮入群: [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15)[![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK),如果无反应,可以自行搜索群号进行添加 )
16-
1. 由于群容量有限即将爆满,现开启付费入群模式,并不定期清理长时间不活跃人士
16+
1. 由于群容量有限,即将爆满,故开启付费入群模式以保证只有真实交流需求的人进入,并为保证群的活跃度,将不定期清理长时间不活跃的同学
1717
1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入;
1818
1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB
1919
1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com
@@ -25,12 +25,12 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK
2525
===========
2626

2727
## 版本说明
28-
1. 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request;
29-
1. BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版);
28+
1. 本项目定为每两个月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request;
29+
1. BUG修复和新特性一般会先发布成小版本作为临时测试版本(如2.0.1-beta,2.0.2-beta等,即尾号不为0,并添加beta字样,以区别于正式版);
3030
1. 目前最新版本号为 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) ,也可以通过访问链接 [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22)[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22)
3131
分别查看所有最新的版本。
3232

33-
## Maven & Gradle
33+
## Maven & Gradle 最新正式版本
3434

3535
* 公众号(订阅号、服务号):
3636

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.github.binarywang</groupId>
77
<artifactId>weixin-java-parent</artifactId>
8-
<version>2.5.0-SNAPSHOT</version>
8+
<version>2.4.4-beta</version>
99
<packaging>pom</packaging>
1010
<name>WeiXin Java Tools - Parent</name>
1111
<description>微信公众号、企业号上级POM</description>
@@ -69,6 +69,11 @@
6969
<email>[email protected]</email>
7070
<url>https://github.com/johnnytung</url>
7171
</developer>
72+
<developer>
73+
<name>Jonk</name>
74+
<email>[email protected]</email>
75+
<url>https://github.com/aimilin6688</url>
76+
</developer>
7277
</developers>
7378

7479
<scm>

weixin-java-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>weixin-java-parent</artifactId>
9-
<version>2.5.0-SNAPSHOT</version>
9+
<version>2.4.4-beta</version>
1010
</parent>
1111

1212
<artifactId>weixin-java-common</artifactId>

weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public class WxError implements Serializable {
2020
private String json;
2121

2222
public static WxError fromJson(String json) {
23-
WxError error = WxGsonBuilder.create().fromJson(json, WxError.class);
24-
return error;
23+
return WxGsonBuilder.create().fromJson(json, WxError.class);
2524
}
2625

2726
public static Builder newBuilder() {

weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java

Lines changed: 70 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public class StandardSession implements WxSession, InternalSession {
1111
/**
1212
* The string manager for this package.
1313
*/
14-
protected static final StringManager sm =
15-
StringManager.getManager(Constants.Package);
14+
protected static final StringManager sm = StringManager.getManager(Constants.Package);
1615
/**
1716
* Type array.
1817
*/
19-
protected static final String EMPTY_ARRAY[] = new String[0];
18+
private static final String[] EMPTY_ARRAY = new String[0];
19+
2020
// ------------------------------ WxSession
2121
protected Map<String, Object> attributes = new ConcurrentHashMap<>();
2222
/**
@@ -71,20 +71,23 @@ public StandardSession(InternalSessionManager manager) {
7171
@Override
7272
public Object getAttribute(String name) {
7373

74-
if (!isValidInternal())
74+
if (!isValidInternal()) {
7575
throw new IllegalStateException
76-
(sm.getString("sessionImpl.getAttribute.ise"));
76+
(sm.getString("sessionImpl.getAttribute.ise"));
77+
}
7778

78-
if (name == null) return null;
79+
if (name == null) {
80+
return null;
81+
}
7982

80-
return (this.attributes.get(name));
83+
return this.attributes.get(name);
8184
}
8285

8386
@Override
8487
public Enumeration<String> getAttributeNames() {
85-
if (!isValidInternal())
86-
throw new IllegalStateException
87-
(sm.getString("sessionImpl.getAttributeNames.ise"));
88+
if (!isValidInternal()) {
89+
throw new IllegalStateException(sm.getString("sessionImpl.getAttributeNames.ise"));
90+
}
8891

8992
Set<String> names = new HashSet<>();
9093
names.addAll(this.attributes.keySet());
@@ -94,9 +97,9 @@ public Enumeration<String> getAttributeNames() {
9497
@Override
9598
public void setAttribute(String name, Object value) {
9699
// Name cannot be null
97-
if (name == null)
98-
throw new IllegalArgumentException
99-
(sm.getString("sessionImpl.setAttribute.namenull"));
100+
if (name == null) {
101+
throw new IllegalArgumentException(sm.getString("sessionImpl.setAttribute.namenull"));
102+
}
100103

101104
// Null value is the same as removeAttribute()
102105
if (value == null) {
@@ -105,9 +108,9 @@ public void setAttribute(String name, Object value) {
105108
}
106109

107110
// Validate our current state
108-
if (!isValidInternal())
109-
throw new IllegalStateException(sm.getString(
110-
"sessionImpl.setAttribute.ise", getIdInternal()));
111+
if (!isValidInternal()) {
112+
throw new IllegalStateException(sm.getString("sessionImpl.setAttribute.ise", getIdInternal()));
113+
}
111114

112115
this.attributes.put(name, value);
113116

@@ -121,8 +124,7 @@ public void removeAttribute(String name) {
121124
@Override
122125
public void invalidate() {
123126
if (!isValidInternal())
124-
throw new IllegalStateException
125-
(sm.getString("sessionImpl.invalidate.ise"));
127+
throw new IllegalStateException(sm.getString("sessionImpl.invalidate.ise"));
126128

127129
// Cause this session to expire
128130
expire();
@@ -131,12 +133,11 @@ public void invalidate() {
131133

132134
@Override
133135
public WxSession getSession() {
134-
135136
if (this.facade == null) {
136137
this.facade = new StandardSessionFacade(this);
137138
}
138-
return (this.facade);
139139

140+
return this.facade;
140141
}
141142

142143
/**
@@ -185,12 +186,14 @@ public void setValid(boolean isValid) {
185186

186187
@Override
187188
public String getIdInternal() {
188-
return (this.id);
189+
return this.id;
189190
}
190191

191192
protected void removeAttributeInternal(String name) {
192193
// Avoid NPE
193-
if (name == null) return;
194+
if (name == null) {
195+
return;
196+
}
194197

195198
// Remove this attribute from our collection
196199
this.attributes.remove(name);
@@ -202,19 +205,22 @@ public void expire() {
202205
// Check to see if session has already been invalidated.
203206
// Do not check expiring at this point as expire should not return until
204207
// isValid is false
205-
if (!this.isValid)
208+
if (!this.isValid) {
206209
return;
210+
}
207211

208212
synchronized (this) {
209213
// Check again, now we are inside the sync so this code only runs once
210214
// Double check locking - isValid needs to be volatile
211215
// The check of expiring is to ensure that an infinite loop is not
212216
// entered as per bug 56339
213-
if (this.expiring || !this.isValid)
217+
if (this.expiring || !this.isValid) {
214218
return;
219+
}
215220

216-
if (this.manager == null)
221+
if (this.manager == null) {
217222
return;
223+
}
218224

219225
// Mark this session as "being expired"
220226
this.expiring = true;
@@ -230,9 +236,9 @@ public void expire() {
230236
this.expiring = false;
231237

232238
// Unbind any objects associated with this session
233-
String keys[] = keys();
234-
for (int i = 0; i < keys.length; i++) {
235-
removeAttributeInternal(keys[i]);
239+
String[] keys = keys();
240+
for (String key : keys) {
241+
removeAttributeInternal(key);
236242
}
237243
}
238244

@@ -273,13 +279,15 @@ public void setMaxInactiveInterval(int interval) {
273279

274280
@Override
275281
public void setId(String id) {
276-
if ((this.id != null) && (this.manager != null))
282+
if ((this.id != null) && (this.manager != null)) {
277283
this.manager.remove(this);
284+
}
278285

279286
this.id = id;
280287

281-
if (this.manager != null)
288+
if (this.manager != null) {
282289
this.manager.add(this);
290+
}
283291
}
284292

285293
/**
@@ -295,21 +303,41 @@ protected String[] keys() {
295303

296304
@Override
297305
public boolean equals(Object o) {
298-
if (this == o) return true;
299-
if (!(o instanceof StandardSession)) return false;
306+
if (this == o) {
307+
return true;
308+
}
309+
if (!(o instanceof StandardSession)) {
310+
return false;
311+
}
300312

301313
StandardSession session = (StandardSession) o;
302314

303-
if (this.creationTime != session.creationTime) return false;
304-
if (this.expiring != session.expiring) return false;
305-
if (this.isValid != session.isValid) return false;
306-
if (this.maxInactiveInterval != session.maxInactiveInterval) return false;
307-
if (this.thisAccessedTime != session.thisAccessedTime) return false;
308-
if (!this.accessCount.equals(session.accessCount)) return false;
309-
if (!this.attributes.equals(session.attributes)) return false;
310-
if (!this.facade.equals(session.facade)) return false;
311-
if (!this.id.equals(session.id)) return false;
312-
return this.manager.equals(session.manager);
315+
if (this.creationTime != session.creationTime) {
316+
return false;
317+
}
318+
if (this.expiring != session.expiring) {
319+
return false;
320+
}
321+
if (this.isValid != session.isValid) {
322+
return false;
323+
}
324+
if (this.maxInactiveInterval != session.maxInactiveInterval) {
325+
return false;
326+
}
327+
if (this.thisAccessedTime != session.thisAccessedTime) {
328+
return false;
329+
}
330+
if (this.accessCount.get() != session.accessCount.get()) {
331+
return false;
332+
}
333+
if (!this.attributes.equals(session.attributes)) {
334+
return false;
335+
}
336+
if (!this.facade.equals(session.facade)) {
337+
return false;
338+
}
339+
340+
return this.id.equals(session.id) && this.manager.equals(session.manager);
313341

314342
}
315343

weixin-java-cp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.github.binarywang</groupId>
88
<artifactId>weixin-java-parent</artifactId>
9-
<version>2.5.0-SNAPSHOT</version>
9+
<version>2.4.4-beta</version>
1010
</parent>
1111

1212
<artifactId>weixin-java-cp</artifactId>

0 commit comments

Comments
 (0)