code: @GuardedBy("readers")
      private void releaseSegmentsIfNeeded() throws ReaderNotInReaderGroupException {
          releaseSealedSegments();
          Segment segment = groupState.findSegmentToReleaseIfRequired();
          if (segment != null) {
              log.info("{} releasing segment {}", this, segment);
              EventSegmentReader reader = readers.stream().filter(r -> r.getSegmentId().equals(segment)).findAny().orElse(null);
              if (reader != null) {
                  if (groupState.releaseSegment(segment, reader.getOffset(), getLag())) {
                      readers.remove(reader);
                      reader.close();
                  }
              }
          }
      }
docs: Releases segments. This must not be invoked except immediately after a checkpoint.