diff --git a/src/main/java/ru/vk/itmo/solnyshkoksenia/DaoImpl.java b/src/main/java/ru/vk/itmo/solnyshkoksenia/DaoImpl.java index 52e350fc2..f1c3488ea 100644 --- a/src/main/java/ru/vk/itmo/solnyshkoksenia/DaoImpl.java +++ b/src/main/java/ru/vk/itmo/solnyshkoksenia/DaoImpl.java @@ -110,16 +110,16 @@ private void autoFlush() throws IOException { } private void tryFlush() { - State curState = this.curState.checkAndGet(); + State state = this.curState.checkAndGet(); try { - curState.flush(); + state.flush(); } catch (IOException e) { throw new DaoException("Flush failed", e); } lock.writeLock().lock(); try { - this.curState = new State(curState.config, curState.storage, new ConcurrentSkipListMap<>(comparator), + this.curState = new State(state.config, state.storage, new ConcurrentSkipListMap<>(comparator), new DiskStorage(DiskStorage.loadOrRecover(path, arena), path)); } catch (IOException e) { throw new DaoException("Cannot recover storage on disk", e); diff --git a/src/main/java/ru/vk/itmo/solnyshkoksenia/storage/DiskStorage.java b/src/main/java/ru/vk/itmo/solnyshkoksenia/storage/DiskStorage.java index 7a687255e..a04bb49e5 100644 --- a/src/main/java/ru/vk/itmo/solnyshkoksenia/storage/DiskStorage.java +++ b/src/main/java/ru/vk/itmo/solnyshkoksenia/storage/DiskStorage.java @@ -50,8 +50,8 @@ public Iterator> range( @Override protected boolean skip(Triple memorySegmentEntry) { if (memorySegmentEntry.expiration() != null) { - return memorySegmentEntry.value() == null || - memorySegmentEntry.expiration().toArray(ValueLayout.JAVA_LONG_UNALIGNED)[0] + return memorySegmentEntry.value() == null + || memorySegmentEntry.expiration().toArray(ValueLayout.JAVA_LONG_UNALIGNED)[0] <= System.currentTimeMillis(); } return memorySegmentEntry.value() == null;