code: private CompletableFuture<Void> trySealStreamSegment(SegmentMetadata metadata, Duration timeout) {
          if (metadata.isSealed()) {
              return CompletableFuture.completedFuture(null);
          } else {
              // It is OK to ignore StreamSegmentSealedException as the segment may have already been sealed by a concurrent
              // call to this or via some other operation.
              return Futures.exceptionallyExpecting(
                      this.durableLog.add(new StreamSegmentSealOperation(metadata.getId()), timeout),
                      ex -> ex instanceof StreamSegmentSealedException,
                      null);
          }
      }
docs: Attempts to seal a Segment that may already be sealed.
  
  @param metadata The SegmentMetadata for the Segment to Seal.
  @param timeout  Timeout for the operation.
  @return A CompletableFuture that will indicate when the operation completes. If the given segment is already sealed,
  this future will already be completed, otherwise it will complete once the seal is performed.