Skip to content

Commit

Permalink
ISPN-9002 LocalModeNoPassivationTest.testValuesWithEvictedEntries random
Browse files Browse the repository at this point in the history
failures

* Fixed issue with retrieval during close
  • Loading branch information
wburns authored and rvansa committed May 4, 2018
1 parent a974881 commit 3853c54
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.persistence.util;

import java.lang.invoke.MethodHandles;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
Expand All @@ -20,6 +21,8 @@
import org.infinispan.util.concurrent.TimeoutException;
import org.infinispan.util.concurrent.WithinThreadExecutor;
import org.infinispan.util.function.CloseableSupplier;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;

/**
* A closeable supplier that provides a way to supply cache entries from a given persistence manager. On the first
Expand All @@ -30,6 +33,9 @@
* @since 8.0
*/
public class PersistenceManagerCloseableSupplier<K, V> implements CloseableSupplier<CacheEntry<K, V>> {
private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass());
private static final boolean trace = log.isTraceEnabled();

private final Executor executor;
private final PersistenceManager manager;
private final KeyFilter<K> filter;
Expand Down Expand Up @@ -126,7 +132,7 @@ public CacheEntry<K, V> get() throws TimeoutException {
closeLock.lock();
try {
// If is possible that someone inserted a value and then acquired the close lock - thus we must recheck
if (closed || (entry = queue.poll()) != null) {
if ((entry = queue.poll()) != null || closed) {
break;
}
long targetTime = System.nanoTime() + unit.toNanos(timeout);
Expand All @@ -145,6 +151,9 @@ public CacheEntry<K, V> get() throws TimeoutException {
if (interrupted) {
Thread.currentThread().interrupt();
}
if (trace) {
log.tracef("Returning entry: " + entry);
}
return entry;
}

Expand Down

0 comments on commit 3853c54

Please sign in to comment.