MCPcopy Index your code
hub / github.com/apache/tomcat / processExpires

Method processExpires

java/org/apache/catalina/session/StoreBase.java:123–186  ·  view source on GitHub ↗

Called by our background reaper thread to check if Sessions saved in our store are subject of being expired. If so expire the Session and remove it from the Store.

()

Source from the content-addressed store, hash-verified

121 * so expire the Session and remove it from the Store.
122 */
123 public void processExpires() {
124 String[] keys;
125
126 if (!getState().isAvailable()) {
127 return;
128 }
129
130 try {
131 keys = expiredKeys();
132 } catch (IOException ioe) {
133 manager.getContext().getLogger().error(sm.getString("store.keysFail"), ioe);
134 return;
135 }
136 if (manager.getContext().getLogger().isTraceEnabled()) {
137 manager.getContext().getLogger()
138 .trace(getStoreName() + ": processExpires check number of " + keys.length + " sessions");
139 }
140
141 long timeNow = System.currentTimeMillis();
142
143 for (String key : keys) {
144 try {
145 Session session = load(key);
146 if (session == null) {
147 continue;
148 }
149 int timeIdle = (int) ((timeNow - session.getThisAccessedTime()) / 1000L);
150 if (timeIdle < session.getMaxInactiveInterval()) {
151 continue;
152 }
153 if (manager.getContext().getLogger().isTraceEnabled()) {
154 manager.getContext().getLogger()
155 .trace(getStoreName() + ": processExpires expire store session " + key);
156 }
157 boolean isLoaded = false;
158 if (manager instanceof PersistentManagerBase) {
159 isLoaded = ((PersistentManagerBase) manager).isLoaded(key);
160 } else {
161 try {
162 if (manager.findSession(key) != null) {
163 isLoaded = true;
164 }
165 } catch (IOException ioe) {
166 // Ignore - session will be expired
167 }
168 }
169 if (isLoaded) {
170 // recycle old backup session
171 session.recycle();
172 } else {
173 // expire swapped out session
174 session.expire();
175 }
176 remove(key);
177 } catch (Exception e) {
178 manager.getContext().getLogger().error(sm.getString("store.expireFail", key), e);
179 try {
180 remove(key);

Callers

nothing calls this directly

Calls 15

expiredKeysMethod · 0.95
getStoreNameMethod · 0.95
getThisAccessedTimeMethod · 0.95
recycleMethod · 0.95
expireMethod · 0.95
isLoadedMethod · 0.80
isAvailableMethod · 0.65
getStateMethod · 0.65
errorMethod · 0.65
getLoggerMethod · 0.65
getContextMethod · 0.65

Tested by

no test coverage detected