You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2013/01/10 17:01:36 UTC
svn commit: r1431456 -
/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Author: markt
Date: Thu Jan 10 16:01:35 2013
New Revision: 1431456
URL: http://svn.apache.org/viewvc?rev=1431456&view=rev
Log:
Remove unnecessary null-check after further analysis prompted by FindBugs
Modified:
commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1431456&r1=1431455&r2=1431456&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java Thu Jan 10 16:01:35 2013
@@ -325,7 +325,6 @@ public class GenericKeyedObjectPool<K,T>
* @throws NoSuchElementException if a keyed object instance cannot be
* returned.
*/
- @SuppressWarnings("null") // objectDeque will always be non-null
public T borrowObject(K key, long borrowMaxWaitMillis) throws Exception {
assertOpen();
@@ -366,9 +365,7 @@ public class GenericKeyedObjectPool<K,T>
p = null;
}
} else {
- if (objectDeque != null) {
- p = objectDeque.getIdleObjects().pollFirst();
- }
+ p = objectDeque.getIdleObjects().pollFirst();
if (p == null) {
create = true;
p = create(key);
@@ -552,7 +549,7 @@ public class GenericKeyedObjectPool<K,T>
"Object not currently part of this pool");
}
synchronized (p) {
- if (p.getState() != PooledObjectState.INVALID) {
+ if (p.getState() != PooledObjectState.INVALID) {
destroy(key, p, true);
}
}
@@ -1030,6 +1027,9 @@ public class GenericKeyedObjectPool<K,T>
/*
* register() and deregister() must always be used as a pair.
+ *
+ * If this method returns without throwing an exception then it will never
+ * return null.
*/
private ObjectDeque<T> register(K k) {
Lock lock = keyLock.readLock();