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.
()
| 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); |
nothing calls this directly
no test coverage detected