@@ -211,9 +211,9 @@ public int read(final byte[] b, final int targetOffset, final int len)
211211 // calculate local offsets
212212 final int pageOffset = globalToLocalOffset (offset );
213213 int localLength = pageSize - pageOffset ;
214- if ( read + localLength > readLength ) {
215- localLength = readLength - read ;
216- }
214+ localLength = Math . min ( localLength , readLength - read );
215+ localLength = Math . min ( localLength , b . length - localTargetOff ) ;
216+ if ( localLength == 0 ) break ; // we've read all we can
217217
218218 // copy the data
219219 System .arraycopy (currentPage , pageOffset , b , localTargetOff , localLength );
@@ -281,7 +281,7 @@ private class LRUReplacementStrategy {
281281 public LRUReplacementStrategy (final int numSlots ) {
282282 queue = new ArrayDeque <>(numSlots );
283283
284- // fill the que
284+ // fill the queue
285285 for (int i = 0 ; i < numSlots ; i ++) {
286286 queue .add (i );
287287 }
@@ -295,12 +295,12 @@ public LRUReplacementStrategy(final int numSlots) {
295295 * the id of the slot that has been accessed
296296 */
297297 public void accessed (final int slotID ) {
298- // put accessed element to the end of the que
298+ // put accessed element to the end of the queue
299299 queue .remove (slotID );
300300 queue .add (slotID );
301301 }
302302
303- public int pickVictim (final int pageID ) {
303+ public int pickVictim (@ SuppressWarnings ( "unused" ) final int pageID ) {
304304 return queue .peek ();
305305 }
306306 }
0 commit comments