private void removeTransientTicketIfNecessary(final PasswordResetRequest resetRequest) {
        Optional.ofNullable(resetRequest)
            .map(PasswordResetRequest::getPasswordResetTicket)
            .filter(TicketGrantingTicketAwareTicket.class::isInstance)
            .map(TicketGrantingTicketAwareTicket.class::cast)
            .filter(r -> r.getExpirationPolicy().isExpired(r))
            .ifPresent(token -> FunctionUtils.doAndHandle(__ -> ticketRegistrySupport.getTicketRegistry().deleteTicket(token)));
    }
This is {@link VerifyPasswordResetRequestAction}.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-pm-webflow/src/main/java/org/apereo/cas/pm/web/flow/actions/VerifyPasswordResetRequestAction.java