Commit c22230a4 authored by Andy Wilkinson's avatar Andy Wilkinson

Try making FilePool static to fix the Mockito problem on Bamboo

parent e11b7aff
...@@ -67,7 +67,7 @@ public class RandomAccessDataFile implements RandomAccessData { ...@@ -67,7 +67,7 @@ public class RandomAccessDataFile implements RandomAccessData {
throw new IllegalArgumentException("File must exist"); throw new IllegalArgumentException("File must exist");
} }
this.file = file; this.file = file;
this.filePool = new FilePool(concurrentReads); this.filePool = new FilePool(file, concurrentReads);
this.offset = 0L; this.offset = 0L;
this.length = file.length(); this.length = file.length();
} }
...@@ -229,7 +229,9 @@ public class RandomAccessDataFile implements RandomAccessData { ...@@ -229,7 +229,9 @@ public class RandomAccessDataFile implements RandomAccessData {
* Manage a pool that can be used to perform concurrent reads on the underlying * Manage a pool that can be used to perform concurrent reads on the underlying
* {@link RandomAccessFile}. * {@link RandomAccessFile}.
*/ */
class FilePool { static class FilePool {
private final File file;
private final int size; private final int size;
...@@ -237,7 +239,8 @@ public class RandomAccessDataFile implements RandomAccessData { ...@@ -237,7 +239,8 @@ public class RandomAccessDataFile implements RandomAccessData {
private final Queue<RandomAccessFile> files; private final Queue<RandomAccessFile> files;
FilePool(int size) { FilePool(File file, int size) {
this.file = file;
this.size = size; this.size = size;
this.available = new Semaphore(size); this.available = new Semaphore(size);
this.files = new ConcurrentLinkedQueue<RandomAccessFile>(); this.files = new ConcurrentLinkedQueue<RandomAccessFile>();
...@@ -249,7 +252,7 @@ public class RandomAccessDataFile implements RandomAccessData { ...@@ -249,7 +252,7 @@ public class RandomAccessDataFile implements RandomAccessData {
if (file != null) { if (file != null) {
return file; return file;
} }
return new RandomAccessFile(RandomAccessDataFile.this.file, "r"); return new RandomAccessFile(this.file, "r");
} }
public void release(RandomAccessFile file) { public void release(RandomAccessFile file) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment