MutableRecordNumbers implements RecordNumbers { @Override public int getOffset(int recordNumber) { int recordEntry = getRecordEntry(recordEntries, recordNumber); if (recordEntry == -1) { synchronized (this) { recordEntry = getRecordEntry(recordEntries, recordNumber); } } return recordEntry; } MutableRecordNumbers(); @Override int getOffset(int recordNumber); @NotNull @Override synchronized Iterator<Entry> iterator(); synchronized int size();  }
@Test public void nonExistingRecordNumberShouldReturnSentinel() { assertEquals(-1, new MutableRecordNumbers().getOffset(42)); }