Skip to content

Instantly share code, notes, and snippets.

@anuraaga
Last active April 25, 2016 08:16
Show Gist options
  • Save anuraaga/f56ae65a9fd3975afe99cc725108850a to your computer and use it in GitHub Desktop.
Save anuraaga/f56ae65a9fd3975afe99cc725108850a to your computer and use it in GitHub Desktop.
Caffeine <=2.2.7 deadlock repro test
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import com.github.benmanes.caffeine.cache.AsyncLoadingCache;
import com.github.benmanes.caffeine.cache.Caffeine;
public class CaffeineTest {
@Test(timeout = 5000)
public void deadlock() throws Exception {
CompletableFuture<String> future = new CompletableFuture<>();
AsyncLoadingCache<String, String> cache = Caffeine
.newBuilder()
.buildAsync((k, e) -> future);
cache.synchronous().refresh("TEST");
CompletableFuture<String> get = cache.get("TEST");
future.complete("success");
assertEquals("success", get.get());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment