Skip to content

Commit

Permalink
Optimize servlet caching filter
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Pinčuk <alexander.v.pinchuk@gmail.com>
  • Loading branch information
avpinchuk committed Jan 16, 2024
1 parent 0c3fcb0 commit a754142
Showing 1 changed file with 9 additions and 0 deletions.
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -158,6 +159,14 @@ public void doFilter (ServletRequest srequest, ServletResponse sresponse,
* same cache entry, then all but the first thread will block.
*/
waitForRefresh = waitForRefresh(request, key, index);

// Recheck because other threads may already put entry to cache
if (!waitForRefresh) {
entry = (HttpCacheEntry) cache.get(key);
if (entry != null && entry.isValid()) {
entryReady = true;
}
}
}
} while (waitForRefresh);
} else {
Expand Down

0 comments on commit a754142

Please sign in to comment.