Browse Source

Fix ConcurrentReferenceHashMap max constraints

Update calculateShift to respect the maximum upper bound as well as the
minimum value.

Issue: SPR-11720

(cherry picked from commit 16410cad)
pull/545/head
HejiaHo 12 years ago committed by Phillip Webb
parent
commit
ac85eab372
  1. 2
      spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java

2
spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java

@ -383,7 +383,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
protected static int calculateShift(int minimumValue, int maximumValue) { protected static int calculateShift(int minimumValue, int maximumValue) {
int shift = 0; int shift = 0;
int value = 1; int value = 1;
while (value < minimumValue && value < minimumValue) { while (value < minimumValue && value < maximumValue) {
value <<= 1; value <<= 1;
shift++; shift++;
} }

Loading…
Cancel
Save