Should be called in a synchronized (this) block, and when !closed
@param requestedTick
@param expiry true if this is called due to expiry of the tick, else false
@return true if this method transitioned the state of requestedTick, else false
776945
private boolean cancelRequestInternal(
    AORequestedTick requestedTick,
    boolean expiry)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(
        tc,
        "cancelRequestInternal",
        new Object[] { requestedTick, Boolean.valueOf(expiry)});

    // cancel the timer only if !expiry, since expiry implies timer has already occured.
    boolean transitionOccured = requestedTick.expire(!expiry);
    if (transitionOccured)
    { // successfully expired
      listOfRequests.remove(requestedTick);
      tableOfRequests.remove(requestedTick.objTick);

      // start the idle timer if no element left in listOfRequests
      // and set isready to false
      if (listOfRequests.isEmpty())
      {
        if (idleTimeout > 0)
          this.idleHandler = am.create(idleTimeout, this);
        if (isready)
        {
          isready = false;
          ck.notReady();
        }
      }
    } // end if (transitionOccured)

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "cancelRequestInternal", Boolean.valueOf(transitionOccured));

    return transitionOccured;
  }
514016
function setExpiry(key, ms, req) {
  var rval = this.getRawKey(key);
  if(rval === undefined) return 0;
  // expiry is in the past or now, delete immediately
  // but return 1 to indicate the expiry was set
  if(ms <= Date.now()) {
    this.delKey(key, req);
    return 1;
  }
  if(!this._expires[key]) {
    this._ekeys.push(key);
  }
  this._expires[key] = ms;
  rval.e = ms;
  return 1;
}
625870
public boolean hasExpired() {
        if (maxAge == 0) return true;

        // if not specify max-age, this cookie should be
        // discarded when user agent is to be closed, but
        // it is not expired.
        if (maxAge == MAX_AGE_UNSPECIFIED) return false;

        long deltaSecond = (System.currentTimeMillis() - whenCreated) / 1000;
        if (deltaSecond > maxAge)
            return true;
        else
            return false;
    }
479751
@Override
    public T poll() {
        T old = null;

        boolean expedited = false;

        synchronized (this) {
            if (numberOfUsedExpeditedSlots.get() > 0) {
                old = expeditedExtract();
                numberOfUsedExpeditedSlots.getAndDecrement();
                expedited = true;
            } else if (numberOfUsedSlots.get() > 0) {
                old = extract();
                numberOfUsedSlots.getAndDecrement();
            }
        }

        if (old != null) {
            //TODO if expedited is added for put or offer with timeout add notification here
            if (!expedited)
                notifyPut_();
        }

        return old;
    }
728059
public final void cancelRequest(long tick)
  {
    Long objTick = Long.valueOf(tick);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "cancelRequest", objTick);

    ArrayList<AORequestedTick> satisfiedTicks = null;
    
    try
    {
      this.lock();
      try
      {
        // it is possible that this event occurs after this object is closed.
        // it is safe to ignore it since we must have already transitioned the tick to its final state
        if (closed)
        {
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "cancelRequest");
  
          return;
        }
        AORequestedTick requestedTick =
          (AORequestedTick) tableOfRequests.get(objTick);
        
        if (requestedTick != null)
        {
          boolean transitionOccured = cancelRequestInternal(requestedTick, false);
        
          // If we expired the request and have more then process those
          // requests now
          if (transitionOccured && !listOfRequests.isEmpty())
            satisfiedTicks = processQueuedMsgs(null);
        }
  
      }
      finally
      {
        this.unlock();
      }
    }
    catch(SINotPossibleInCurrentConfigurationException e)
    {
      // No FFDC code needed
      notifyException(e);
    }
    
    if (satisfiedTicks != null)
    {
      // inform parent about satisfied ticks - outside lock
      int length = satisfiedTicks.size();
      for (int i = 0; i < length; i++)
      {
        AORequestedTick aotick = (AORequestedTick) satisfiedTicks.get(i);
        parent.satisfiedRequest(aotick.tick, aotick.getMessage());
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "cancelRequest");
  }
627083
private void writeSilenceInternal(TickRange tr, boolean forced)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "writeSilenceInternal", new Object[] { tr, Boolean.valueOf(forced) });

        List msgList = null;

        // Take lock on target stream and hold it until messages have been
        // added to batch by deliverOrderedMessages 
        synchronized (this)
        {
            // We are only allowed to remove a message from the stream and replace 
            // it with Silence if it has not yet been added to a Batch to be delivered
            // We know that this can't happen asynchronously once we hold the targetStream lock
            // and the nextCompletedPrefix tells us the last message in the current batch 
            if (!forced || tr.valuestamp > this.nextCompletedPrefix)
            {

                synchronized (oststream)
                {
                    // Get the completedPrefix 
                    long completedPrefix = oststream.getCompletedPrefix();

                    // check if all ticks in Silence msg are already acked as if
                    // so they will be changed to Completed anyway and we don't need
                    // to do it now
                    if (tr.endstamp > completedPrefix)
                    {
                        if (forced == false)
                            oststream.writeRange(tr);
                        else
                            oststream.writeCompletedRangeForced(tr);

                        // Get updated completedPrefix
                        completedPrefix = oststream.getCompletedPrefix();

                    }

                    // The completedPrefix may have advanced when the Silence message
                    // was writen to the stream or both
                    if ((completedPrefix + 1) > doubtHorizon)
                    {
                        // advance the doubt horizon
                        doubtHorizon = completedPrefix + 1;

                        // now call the method which trys to advance the doubtHorizon
                        // from it's current setting by moving over any ticks in Completed 
                        // state and sending Values messages until it reaches a tick in
                        // Unknown or Requested
                        msgList = advanceDoubtHorizon(null);
                    }

                    if ((doubtHorizon - 1) > unknownHorizon)
                        unknownHorizon = doubtHorizon - 1;

                    // the message was writen to the stream
                    // see if this message created a gap
                    if (tr.endstamp > unknownHorizon)
                    {
                        // check if gap created
                        if (tr.startstamp > (unknownHorizon + 1))
                        {
                            handleNewGap(unknownHorizon + 1, tr.startstamp - 1);
                        }
                        unknownHorizon = tr.endstamp;
                    }

                    // Reset the health state
                    if (lastNackTick >= 0)
                    {
                        if (tr.startstamp <= lastNackTick && tr.endstamp >= lastNackTick)
                        {
                            getControlAdapter().getHealthState().updateHealth(HealthStateListener.MSG_LOST_ERROR_STATE,
                                                                              HealthState.GREEN);
                            lastNackTick = -1;
                        }
                    }

                    // If the stream is blocked, see if we have a silence for the blocking tick
                    if (isStreamBlocked())
                    {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                            SibTr.debug(tc, "Stream is blocked on tick: " + linkBlockingTick + ", see if we can unblock it");
                        if (tr.endstamp >= linkBlockingTick)
                        {
                            if (tr.startstamp <= linkBlockingTick)
                            {
                                // The stream is no longer blocked
                                setStreamIsBlocked(false, DestinationHandler.OUTPUT_HANDLER_FOUND, null, null);
                            }
                        }
                    } // eof isStreamBlocked()
                } // end sync ( release the oststream lock )

                // Deliver messages outside of synchronise 
                // We do this because deliverOrderedMessages takes the 
                // BatchHandler lock and the BatchHandler callbacks require
                // the stream lock to update the completedPrefix. If we call
                // the BatchHandler when we hold the stream lock it could cause
                // a deadlock
                if (msgList != null)
                {
                    // Call the Input or Output Handler to deliver the messages
                    try
                    {
                        deliverer.deliverOrderedMessages(msgList, this, priority, reliability);
                    } catch (SINotPossibleInCurrentConfigurationException e)
                    {
                        // No FFDC code needed
                        SibTr.exception(tc, e);

                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                            SibTr.debug(tc, "writeSilenceInternal", "GDException");

                        // Dont rethrow the exception. The GD protocols will handle the resend of
                        // the message
                    } catch (SIException e)
                    {
                        // FFDC
                        FFDCFilter.processException(
                                                    e,
                                                    "com.ibm.ws.sib.processor.gd.GuaranteedTargetStream.writeSilenceInternal",
                                                    "1:960:1.110",
                                                    this);

                        SibTr.exception(tc, e);
                        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
                                    new Object[] {
                                                  "com.ibm.ws.sib.processor.gd.GuaranteedTargetStream",
                                                  "1:967:1.110",
                                                  e });

                        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                            SibTr.exit(tc, "writeSilenceInternal", "GDException");

                        throw new SIErrorException(
                                        nls.getFormattedMessage(
                                                                "INTERNAL_MESSAGING_ERROR_CWSIP0002",
                                                                new Object[] {
                                                                              "com.ibm.ws.sib.processor.gd.GuaranteedTargetStream",
                                                                              "1:977:1.110",
                                                                              e },
                                                                null),
                                        e);
                    }
                }

            } // else can't remove as already in batch 
        } // end sync - release lock on target stream

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "writeSilenceInternal");
    }
1244048
public void expire(String sid, final int maxInactiveInterval) {
        final String sessionId = sessionPrefix + ":" + sid;
        try {
            this.executor.execute(new RedisCallback<Void>() {
                public Void execute(Jedis jedis) {
                    jedis.expire(sessionId, maxInactiveInterval);
                    return null;
                }
            });
        } catch (Exception e) {
            log.error("failed to refresh expire time session(key={}) in redis,cause:{}",
                    sessionId, Throwables.getStackTraceAsString(e));
        }
    }
46297
@Override
  public boolean hasExpired(SlotInfo<? extends T> info) throws Exception {
    return firstExpiration.hasExpired(info)
            || secondExpiration.hasExpired(info);
  }
237565
public void tick(long duration, TimeUnit unit) {
        this.date = new Date(date.getTime() + unit.toMillis(duration));
    }
362695
@JsonIgnore
    protected boolean isAccessTokenExpired(final TicketState ticketState) {
        val currentSystemTime = ZonedDateTime.now(ZoneOffset.UTC);
        val creationTime = ticketState.getCreationTime();

        var expirationTime = creationTime.plus(this.maxTimeToLiveInSeconds, ChronoUnit.SECONDS);
        if (currentSystemTime.isAfter(expirationTime)) {
            LOGGER.debug("Access token is expired because the time since creation is greater than maxTimeToLiveInSeconds");
            return true;
        }

        val expirationTimeToKill = ticketState.getLastTimeUsed().plus(this.timeToKillInSeconds, ChronoUnit.SECONDS);
        if (currentSystemTime.isAfter(expirationTimeToKill)) {
            LOGGER.debug("Access token is expired because the time since last use is greater than timeToKillInSeconds");
            return true;
        }
        return false;
    }
795811
protected boolean checkForExpiration(CacheItem item) throws Exception {
        if (item.isExpired(ticks.get())) {
            cacheStoreAdapter.remove(item.getScope(), item.getKey());

            return true;
        } else {
            return false;
        }
    }
743909
@GuardedBy("evictionLock")
  void expireEntries() {
    long now = expirationTicker().read();
    expireAfterAccessEntries(now);
    expireAfterWriteEntries(now);
    expireVariableEntries(now);
  }
1112766
public void checkKeepOrRemove() {
    boolean _hasKeepAfterExpired = heapCache.isKeepAfterExpired();
    if (expiry != 0 || remove || _hasKeepAfterExpired) {
      mutationUpdateHeap();
      return;
    }
    if (_hasKeepAfterExpired) {
      expiredImmediatelyKeepData();
      return;
    }
    expiredImmediatelyAndRemove();
  }
1166280
public boolean hasExpired()
    {
        if ( expiresAt == null ) {
            LOGGER.debug( "hasExpired - token is not expirable" );
            return false;
        }

        long now = System.currentTimeMillis();
        if ( LOGGER.isDebugEnabled() ) {
            LOGGER.debug( "hasExpired? - now: {} expiredAt: {} ", new Date( now ), expiresAt );
        }
        return now > expiresAt.getTime();
    }
19342
public void setExpiry(Date expire) {
        addField(SubscribeOptionFields.expire, FormField.Type.text_single);
        setAnswer(SubscribeOptionFields.expire.getFieldName(), XmppDateTime.formatXEP0082Date(expire));
    }
1189149
private boolean isFresh(final YokeRequest request) {
        // defaults
        boolean etagMatches = true;
        boolean notModified = true;

        // fields
        String modifiedSince = request.getHeader("if-modified-since");
        String noneMatch = request.getHeader("if-none-match");
        String[] noneMatchTokens = null;
        String lastModified = request.response().getHeader("last-modified");
        String etag = request.response().getHeader("etag");

        // unconditional request
        if (modifiedSince == null && noneMatch == null) {
            return false;
        }

        // parse if-none-match
        if (noneMatch != null) {
            noneMatchTokens = noneMatch.split(" *, *");
        }

        // if-none-match
        if (noneMatchTokens != null) {
            etagMatches = false;
            for (String s : noneMatchTokens) {
                if (etag.equals(s) || "*".equals(noneMatchTokens[0])) {
                    etagMatches = true;
                    break;
                }
            }
        }

        // if-modified-since
        if (modifiedSince != null) {
            try {
                Date modifiedSinceDate = parse(modifiedSince);
                Date lastModifiedDate = parse(lastModified);
                notModified = lastModifiedDate.getTime() <= modifiedSinceDate.getTime();
            } catch (ParseException e) {
                notModified = false;
            }
        }

        return etagMatches && notModified;
    }
577592
public boolean refreshSession (String sessionKey, int expireDays)
        throws PersistenceException
    {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, expireDays);
        Date expires = new Date(cal.getTime().getTime());

        // attempt to update an existing session row, returning true if we found and updated it
        return (update("update sessions set expires = '" + expires + "' " +
                       "where authcode = " + JDBCUtil.escape(sessionKey)) == 1);
    }