Skip to content

Commit

Permalink
Move dataSource reset before connection returned
Browse files Browse the repository at this point in the history
Move dataSource reset before connection returned to pool.
If datasource reset after the connection returned to pool, it might reset the datasource after it was allocated to another thread
  • Loading branch information
gkorland committed Dec 17, 2018
1 parent 95aa6a9 commit df1bffa
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3452,12 +3452,13 @@ public Map<String, String> pubsubNumSub(String... channels) {
@Override
public void close() {
if (dataSource != null) {
JedisPoolAbstract pool = this.dataSource;
this.dataSource = null;
if (client.isBroken()) {
this.dataSource.returnBrokenResource(this);
pool.returnBrokenResource(this);
} else {
this.dataSource.returnResource(this);
pool.returnResource(this);
}
this.dataSource = null;
} else {
super.close();
}
Expand Down

0 comments on commit df1bffa

Please sign in to comment.