static Optional<Timestamp> readTimestampOfLastEventInSegment(Path segmentPath) throws IOException {
        byte[] eventBytes = null;
        try (RecordIOReader recordReader = new RecordIOReader(segmentPath)) {
            int blockId = (int) Math.ceil(((Files.size(segmentPath) - VERSION_SIZE) / (double) BLOCK_SIZE)) - 1;;
            while (eventBytes == null && blockId >= 0) { // no event present in last block, try with the one before
                recordReader.seekToBlock(blockId);
                eventBytes = recordReader.readEvent();
                blockId--;
            }
        } catch (NoSuchFileException nsfex) {
            // the segment file may have been removed by the clean consumed feature on the reader side
            return Optional.empty();
        }
        if (eventBytes == null) {
            logger.warn("Cannot find a complete event into the segment file [{}], this is a DLQ segment corruption", segmentPath);
            return Optional.empty();
        }
        return Optional.of(DLQEntry.deserialize(eventBytes).getEntryTime());
    }
@Test
    public void testReadTimestampOfLastEventInSegmentWithDeletedSegment() throws IOException {
        // Exercise
        Optional<Timestamp> timestamp = DeadLetterQueueWriter.readTimestampOfLastEventInSegment(Path.of("non_existing_file.txt"));

        // Verify
        assertTrue(timestamp.isEmpty());
    }