@@ -50,6 +50,10 @@ private FileCache createFileCache(long capacity) {
5050 return FileCacheFactory .createConcurrentLRUFileCache (capacity , CONCURRENCY_LEVEL , new NoopCircuitBreaker (CircuitBreaker .REQUEST ));
5151 }
5252
53+ private FileCache createFileCache (long capacity , CircuitBreaker circuitBreaker ) {
54+ return FileCacheFactory .createConcurrentLRUFileCache (capacity , CONCURRENCY_LEVEL , circuitBreaker );
55+ }
56+
5357 private FileCache createCircuitBreakingFileCache (long capacity ) {
5458 TestCircuitBreaker testCircuitBreaker = new TestCircuitBreaker ();
5559 testCircuitBreaker .startBreaking ();
@@ -204,6 +208,20 @@ public void testComputeThrowCircuitBreakingException() {
204208 assertNull (fileCache .get (path ));
205209 }
206210
211+ public void testEntryNotRemovedCircuitBreaker () {
212+ TestCircuitBreaker circuitBreaker = new TestCircuitBreaker ();
213+ FileCache fileCache = createFileCache (MEGA_BYTES , circuitBreaker );
214+ Path path = createPath ("0" );
215+ fileCache .put (path , new StubCachedIndexInput (8 * MEGA_BYTES ));
216+ // put should succeed since circuit breaker hasn't tripped yet
217+ assertEquals (fileCache .get (path ).length (), 8 * MEGA_BYTES );
218+ circuitBreaker .startBreaking ();
219+ // compute should throw CircuitBreakingException but shouldn't remove entry already present
220+ assertThrows (CircuitBreakingException .class , () -> fileCache .compute (path , (p , i ) -> new StubCachedIndexInput (2 * MEGA_BYTES )));
221+ assertNotNull (fileCache .get (path ));
222+ assertEquals (fileCache .get (path ).length (), 8 * MEGA_BYTES );
223+ }
224+
207225 public void testRemove () {
208226 FileCache fileCache = createFileCache (MEGA_BYTES );
209227 for (int i = 0 ; i < 4 ; i ++) {
0 commit comments