You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2020/02/11 14:17:58 UTC

[GitHub] [knox] pzampino commented on a change in pull request #257: KNOX-2214 - Periodic job to evict expired tokens

pzampino commented on a change in pull request #257: KNOX-2214 - Periodic job to evict expired tokens
URL: https://github.com/apache/knox/pull/257#discussion_r377660374
 
 

 ##########
 File path: gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenStateService.java
 ##########
 @@ -264,4 +280,29 @@ protected String getTokenDisplayText(final String token) {
     return String.format(Locale.ROOT, "%s...%s", token.substring(0, 10), token.substring(token.length() - 3));
   }
 
+  /**
+   * Method that deletes expired tokens based on the token timestamp.
+   */
+  protected void evictExpiredTokens() {
+    try {
+      for (final String token : getTokens()) {
+        if (isExpired(token)) {
+          log.evictToken(getTokenDisplayText(token));
+          removeToken(token);
+        }
+      }
+    } catch(final Exception e) {
 
 Review comment:
   Would it not be better to catch the error for each eviction attempt, and continue trying the others when one fails, rather than failing the whole attempt because of a single error?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services