From 038153a3641b6192240923b3ceacb9e6566f40a3 Mon Sep 17 00:00:00 2001 From: Omri Himelbrand Date: Tue, 27 Apr 2021 17:54:46 +0300 Subject: [PATCH] Update GDWheelPolicy.java A fix for null pointer in migrate. changed the condition of the if statment as to not cause a null pointer exception by trying to access wheel at index that is out of bounds. --- .../cache/simulator/policy/greedy_dual/GDWheelPolicy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GDWheelPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GDWheelPolicy.java index 5bead13885..9651d8b3b0 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GDWheelPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GDWheelPolicy.java @@ -122,7 +122,7 @@ private void migrate(int level) { clockHand[level] = hand; // if C[idx] has advanced a whole round back to 1, call migration(idx+1) - if ((hand == 0) && (level < wheel.length)) { + if ((hand == 0) && (level + 1 < wheel.length)) { migrate(level + 1); }