Skip to content

Commit

Permalink
added logs and removed unnecessary repeated codes
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Feb 7, 2021
1 parent 443d066 commit cf794fc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 28 deletions.
5 changes: 2 additions & 3 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
import redis.clients.jedis.params.LPosParams;
import redis.clients.jedis.util.Pool;
import redis.clients.jedis.util.SafeEncoder;
import redis.clients.jedis.util.Slowlog;

Expand All @@ -40,7 +39,7 @@ public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommand
* @deprecated This will be private in future.
*/
@Deprecated
protected Pool<Jedis> dataSource = null;
protected JedisPoolAbstract dataSource = null;

public Jedis() {
super();
Expand Down Expand Up @@ -3608,7 +3607,7 @@ public Map<String, String> pubsubNumSub(String... channels) {
@Override
public void close() {
if (dataSource != null) {
Pool<Jedis> pool = this.dataSource;
JedisPoolAbstract pool = this.dataSource;
this.dataSource = null;
if (client.isBroken()) {
pool.returnBrokenResource(this);
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/redis/clients/jedis/JedisPool.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package redis.clients.jedis;

import java.net.URI;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocketFactory;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.util.JedisURIHelper;

public class JedisPool extends JedisPoolAbstract {

private static final Logger log = LoggerFactory.getLogger(JedisPool.class);

public JedisPool() {
this(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT);
}
Expand Down Expand Up @@ -329,13 +331,6 @@ public Jedis getResource() {
return jedis;
}

@Override
public void returnBrokenResource(final Jedis resource) {
if (resource != null) {
returnBrokenResourceObject(resource);
}
}

@Override
public void returnResource(final Jedis resource) {
if (resource != null) {
Expand All @@ -344,6 +339,7 @@ public void returnResource(final Jedis resource) {
returnResourceObject(resource);
} catch (Exception e) {
returnBrokenResource(resource);
log.debug("Resource is returned to the pool as broken", e);
}
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/redis/clients/jedis/JedisSentinelPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
import redis.clients.jedis.exceptions.JedisException;

public class JedisSentinelPool extends JedisPoolAbstract {
protected Logger log = LoggerFactory.getLogger(getClass().getName());

/**
* @deprecated This will be private in future.
*/
@Deprecated
protected static Logger log = LoggerFactory.getLogger(JedisSentinelPool.class);

protected final GenericObjectPoolConfig poolConfig;

Expand Down Expand Up @@ -309,13 +314,6 @@ public Jedis getResource() {
}
}

@Override
public void returnBrokenResource(final Jedis resource) {
if (resource != null) {
returnBrokenResourceObject(resource);
}
}

@Override
public void returnResource(final Jedis resource) {
if (resource != null) {
Expand All @@ -324,7 +322,7 @@ public void returnResource(final Jedis resource) {
returnResourceObject(resource);
} catch (Exception e) {
returnBrokenResource(resource);
throw new JedisException("Resource is returned to the pool as broken", e);
log.debug("Resource is returned to the pool as broken", e);
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/redis/clients/jedis/ShardedJedisPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ public ShardedJedis getResource() {
return jedis;
}

@Override
public void returnBrokenResource(final ShardedJedis resource) {
if (resource != null) {
returnBrokenResourceObject(resource);
}
}

@Override
public void returnResource(final ShardedJedis resource) {
if (resource != null) {
Expand Down

0 comments on commit cf794fc

Please sign in to comment.