From c22230a418b58212fbbaf3be586fde483b5f8636 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 31 May 2017 23:24:03 +0100 Subject: [PATCH] Try making FilePool static to fix the Mockito problem on Bamboo --- .../boot/loader/data/RandomAccessDataFile.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java index c6bdc00774..0ee62307c8 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java @@ -67,7 +67,7 @@ public class RandomAccessDataFile implements RandomAccessData { throw new IllegalArgumentException("File must exist"); } this.file = file; - this.filePool = new FilePool(concurrentReads); + this.filePool = new FilePool(file, concurrentReads); this.offset = 0L; this.length = file.length(); } @@ -229,7 +229,9 @@ public class RandomAccessDataFile implements RandomAccessData { * Manage a pool that can be used to perform concurrent reads on the underlying * {@link RandomAccessFile}. */ - class FilePool { + static class FilePool { + + private final File file; private final int size; @@ -237,7 +239,8 @@ public class RandomAccessDataFile implements RandomAccessData { private final Queue files; - FilePool(int size) { + FilePool(File file, int size) { + this.file = file; this.size = size; this.available = new Semaphore(size); this.files = new ConcurrentLinkedQueue(); @@ -249,7 +252,7 @@ public class RandomAccessDataFile implements RandomAccessData { if (file != null) { return file; } - return new RandomAccessFile(RandomAccessDataFile.this.file, "r"); + return new RandomAccessFile(this.file, "r"); } public void release(RandomAccessFile file) {