[java-opensaml COMMIT] in /trunk/opensaml-util/src: main/java/org/opensaml/util/storage/impl/MemoryStorageService.jav...
noreply at shibboleth.net
noreply at shibboleth.net
Tue Apr 30 14:32:28 EDT 2013
Author: scantor
Date: Tue Apr 30 14:32:28 2013
New Revision: 3325
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3325&view=rev
Log:
Test for background cleanup, and a bug fix.
Modified:
trunk/opensaml-util/src/main/java/org/opensaml/util/storage/impl/MemoryStorageService.java
trunk/opensaml-util/src/test/java/org/opensaml/util/storage/StorageServiceTest.java
Modified: trunk/opensaml-util/src/main/java/org/opensaml/util/storage/impl/MemoryStorageService.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-util/src/main/java/org/opensaml/util/storage/impl/MemoryStorageService.java?rev=3325&r1=3324&r2=3325&view=diff
==============================================================================
--- trunk/opensaml-util/src/main/java/org/opensaml/util/storage/impl/MemoryStorageService.java (original)
+++ trunk/opensaml-util/src/main/java/org/opensaml/util/storage/impl/MemoryStorageService.java Tue Apr 30 14:32:28 2013
@@ -429,7 +429,7 @@
private boolean reapWithLock(@Nonnull Map<String, MutableStorageRecord> dataMap, final long expiration) {
return Iterables.removeIf(dataMap.entrySet(), new Predicate<Entry<String, MutableStorageRecord>>() {
- public boolean apply(@Nullable Entry<String, MutableStorageRecord> entry) {
+ public boolean apply(@Nullable final Entry<String, MutableStorageRecord> entry) {
Long exp = entry.getValue().getExpiration();
return exp != null && (exp * 1000) <= expiration;
}
@@ -455,7 +455,7 @@
Iterator<Map<String, MutableStorageRecord>> i = contexts.iterator();
while (i.hasNext()) {
final Map<String, MutableStorageRecord> context = i.next();
- if (reapWithLock(i.next(), now)) {
+ if (reapWithLock(context, now)) {
purged = true;
if (context.isEmpty()) {
i.remove();
Modified: trunk/opensaml-util/src/test/java/org/opensaml/util/storage/StorageServiceTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-util/src/test/java/org/opensaml/util/storage/StorageServiceTest.java?rev=3325&r1=3324&r2=3325&view=diff
==============================================================================
--- trunk/opensaml-util/src/test/java/org/opensaml/util/storage/StorageServiceTest.java (original)
+++ trunk/opensaml-util/src/test/java/org/opensaml/util/storage/StorageServiceTest.java Tue Apr 30 14:32:28 2013
@@ -128,4 +128,21 @@
Assert.assertNull(rec);
}
}
+
+ @Test
+ public void expiration() throws IOException, InterruptedException {
+ String context = Long.toString(random.nextLong());
+
+ for (int i = 1; i <= 100; i++) {
+ shared.createText(context, Integer.toString(i), Integer.toString(i + 1), System.currentTimeMillis() / 1000 + 5);
+ }
+
+ Thread.sleep(5 * 1000);
+
+ for (int i = 1; i <= 100; i++) {
+ StorageRecord rec = shared.readText(context, Integer.toString(i));
+ Assert.assertNull(rec);
+ }
+ }
+
}
More information about the commits
mailing list