### Question:
AbstractKeyValueStore extends LifecycleAdapter { protected final <Value> Value lookup( Key key, Reader<Value> reader ) throws IOException { ValueLookup<Value> lookup = new ValueLookup<>( reader ); long retriesLeft = MAX_LOOKUP_RETRY_COUNT; while ( retriesLeft > 0 ) { ProgressiveState<Key> originalState = this.state; try { return lookup.value( !originalState.lookup( key, lookup ) ); } catch ( FileIsNotMappedException e ) { if ( originalState == this.state ) { throw e; } } retriesLeft--; } throw new IOException( String.format( "Failed to lookup `%s` in key value store, after %d retries", key, MAX_LOOKUP_RETRY_COUNT ) ); } AbstractKeyValueStore( FileSystemAbstraction fs, PageCache pages, DatabaseLayout databaseLayout, RotationMonitor monitor, Logger logger,
            RotationTimerFactory timerFactory, VersionContextSupplier versionContextSupplier, int keySize,
            int valueSize, HeaderField<?>... headerFields ); @Override String toString(); int totalEntriesStored(); final File currentFile(); @Override final void init(); @Override final void start(); @Override final void shutdown(); Iterable<File> allFiles();  }### Answer:
@Test @Resources.Life( STARTED ) @SuppressWarnings( "unchecked" ) public void retryLookupOnConcurrentStoreStateChange() throws IOException { Store store = resourceManager.managed( new Store() ); ProgressiveState<String> workingState = stateWithLookup( () -> true ); ProgressiveState<String> staleState = stateWithLookup( () -> { setState( store, workingState ); throw new FileIsNotMappedException( new File( "/files/was/rotated/concurrently/during/lookup" ) ); } ); setState( store, staleState ); assertEquals( "New state contains stored value", "value", store.lookup( "test", stringReader( "value" ) ) ); verify( staleState, times( 1 ) ).lookup( any(), any() ); verify( workingState, times( 1 ) ).lookup( any(), any() ); }