db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r643870 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
Date Wed, 02 Apr 2008 12:14:46 GMT
Author: kahatlen
Date: Wed Apr  2 05:14:45 2008
New Revision: 643870

URL: http://svn.apache.org/viewvc?rev=643870&view=rev
Log:
DERBY-3582: IndexOutOfBoundsError in ClockPolicy.moveHand

Make sure moveHand() and rotateClock() work if the clock is empty.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java?rev=643870&r1=643869&r2=643870&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/cache/ClockPolicy.java
Wed Apr  2 05:14:45 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) {



Mime
View raw message