@@ -211,9 +211,9 @@ public int read(final byte[] b, final int targetOffset, final int len)
211
211
// calculate local offsets
212
212
final int pageOffset = globalToLocalOffset (offset );
213
213
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
217
217
218
218
// copy the data
219
219
System .arraycopy (currentPage , pageOffset , b , localTargetOff , localLength );
@@ -281,7 +281,7 @@ private class LRUReplacementStrategy {
281
281
public LRUReplacementStrategy (final int numSlots ) {
282
282
queue = new ArrayDeque <>(numSlots );
283
283
284
- // fill the que
284
+ // fill the queue
285
285
for (int i = 0 ; i < numSlots ; i ++) {
286
286
queue .add (i );
287
287
}
@@ -295,12 +295,12 @@ public LRUReplacementStrategy(final int numSlots) {
295
295
* the id of the slot that has been accessed
296
296
*/
297
297
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
299
299
queue .remove (slotID );
300
300
queue .add (slotID );
301
301
}
302
302
303
- public int pickVictim (final int pageID ) {
303
+ public int pickVictim (@ SuppressWarnings ( "unused" ) final int pageID ) {
304
304
return queue .peek ();
305
305
}
306
306
}
0 commit comments