You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2008/04/03 10:08:19 UTC
svn commit: r644211 -
/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
Author: kahatlen
Date: Thu Apr 3 01:08:13 2008
New Revision: 644211
URL: http://svn.apache.org/viewvc?rev=644211&view=rev
Log:
DERBY-3582: IndexOutOfBoundsError in ClockPolicy.moveHand
Merged fix from trunk (revision 643870).
Modified:
db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java?rev=644211&r1=644210&r2=644211&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java Thu Apr 3 01:08:13 2008
@@ -354,10 +354,14 @@
* Get the holder under the clock hand, and move the hand to the next
* holder.
*
- * @return the holder under the clock hand
+ * @return the holder under the clock hand, or {@code null} if the clock is
+ * empty
*/
private Holder moveHand() {
synchronized (clock) {
+ if (clock.isEmpty()) {
+ return null;
+ }
if (hand >= clock.size()) {
hand = 0;
}
@@ -402,6 +406,13 @@
while (itemsToCheck-- > 0 || freeEntries.get() > 0) {
final Holder h = moveHand();
+
+ if (h == null) {
+ // There are no elements in the clock, hence there is no
+ // reusable entry.
+ return null;
+ }
+
final CacheEntry e = h.getEntry();
if (e == null) {