add a number of null check to return methods.
This allows calling these methods on error cleanup paths without having to surround them with if checks all the time.
This commit is contained in:
@@ -80,11 +80,15 @@ public class JedisPool extends Pool<Jedis> {
|
||||
}
|
||||
|
||||
public void returnBrokenResource(final Jedis resource) {
|
||||
returnBrokenResourceObject(resource);
|
||||
if (resource != null) {
|
||||
returnBrokenResourceObject(resource);
|
||||
}
|
||||
}
|
||||
|
||||
public void returnResource(final Jedis resource) {
|
||||
resource.resetState();
|
||||
returnResourceObject(resource);
|
||||
if (resource != null) {
|
||||
resource.resetState();
|
||||
returnResourceObject(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,11 +54,15 @@ public abstract class Pool<T> {
|
||||
}
|
||||
|
||||
public void returnBrokenResource(final T resource) {
|
||||
returnBrokenResourceObject(resource);
|
||||
if (resource != null) {
|
||||
returnBrokenResourceObject(resource);
|
||||
}
|
||||
}
|
||||
|
||||
public void returnResource(final T resource) {
|
||||
returnResourceObject(resource);
|
||||
if (resource != null) {
|
||||
returnResourceObject(resource);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
@@ -81,4 +85,4 @@ public abstract class Pool<T> {
|
||||
throw new JedisException("Could not destroy the pool", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user