@Override
    public synchronized void destroy() {
        if (id < 0) {
            throw new IllegalStateException("Negative segment ID indicates a reserved segment, "
                + "which should not be destroyed. Reserved segments are cleaned up only when "
                + "an entire store is closed, via the close() method rather than destroy().");
        }

        final Bytes keyPrefix = prefixKeyFormatter.getPrefix();

        // this deleteRange() call deletes all entries with the given prefix, because the
        // deleteRange() implementation calls Bytes.increment() in order to make keyTo inclusive
        physicalStore.deleteRange(keyPrefix, keyPrefix);
    }
@Test
    public void shouldNotDestroySegmentWithNegativeId() {
        // reserved segments should not be destroyed. they are cleaned up only when
        // an entire store is closed, via the close() method rather than destroy()
        assertThrows(IllegalStateException.class, () -> negativeIdSegment.destroy());
    }