@@ -419,7 +419,7 @@ private void expandIfNecessary(int dataLength, RandomAccessFile raf) throws IOEx
419
419
previousLength = newLength ;
420
420
} while (remainingBytes < elementLength );
421
421
422
- setLength (newLength );
422
+ setLength (newLength , raf );
423
423
424
424
// Calculate the position of the tail end of the data in the ring buffer
425
425
int endOfLastElement = wrapPosition (last .position + Element .HEADER_LENGTH + last .length );
@@ -449,12 +449,10 @@ private void expandIfNecessary(int dataLength, RandomAccessFile raf) throws IOEx
449
449
/**
450
450
* Sets the length of the file.
451
451
*/
452
- private void setLength (int newLength ) throws IOException {
453
- openAndExecute (raf -> {
454
- // Set new file length (considered metadata) and sync it to storage.
455
- raf .setLength (newLength );
456
- raf .getChannel ().force (true );
457
- });
452
+ private void setLength (int newLength , RandomAccessFile raf ) throws IOException {
453
+ // Set new file length (considered metadata) and sync it to storage.
454
+ raf .setLength (newLength );
455
+ raf .getChannel ().force (true );
458
456
}
459
457
460
458
/**
@@ -588,13 +586,13 @@ public synchronized void remove() throws IOException {
588
586
/**
589
587
* Clears this queue. Truncates the file to the initial size.
590
588
*/
591
- public synchronized void clear (RandomAccessFile raf ) throws IOException {
589
+ private synchronized void clear (RandomAccessFile raf ) throws IOException {
592
590
writeHeader (INITIAL_LENGTH , 0 , 0 , 0 , raf );
593
591
elementCount = 0 ;
594
592
first = Element .NULL ;
595
593
last = Element .NULL ;
596
594
if (fileLength > INITIAL_LENGTH ) {
597
- setLength (INITIAL_LENGTH );
595
+ setLength (INITIAL_LENGTH , raf );
598
596
}
599
597
fileLength = INITIAL_LENGTH ;
600
598
}
0 commit comments