code: boolean releaseSegment(Segment segment, long lastOffset, long timeLag) throws ReaderNotInReaderGroupException {
          sync.updateState((state, updates) -> {
              Set<Segment> segments = state.getSegments(readerId);
              if (segments != null && segments.contains(segment) && state.getCheckpointForReader(readerId) == null
                      && doesReaderOwnTooManySegments(state)) {
                  updates.add(new ReleaseSegment(readerId, segment, lastOffset));
                  updates.add(new UpdateDistanceToTail(readerId, timeLag));
              }
          });
          ReaderGroupState state = sync.getState();
          releaseTimer.reset(calculateReleaseTime(readerId, state));
          acquireTimer.reset(calculateAcquireTime(readerId, state));
          if (!state.isReaderOnline(readerId)) {
              throw new ReaderNotInReaderGroupException(readerId);
          }
          return !state.getSegments(readerId).contains(segment);
      }
docs: Releases a segment to another reader. This reader should no longer read from the segment.
  
  @param segment The segment to be released
  @param lastOffset The offset from which the new owner should start reading from.
  @param timeLag How far the reader is from the tail of the stream in time.
  @return a boolean indicating if the segment was successfully released.
  @throws ReaderNotInReaderGroupException If the reader has been declared offline.