diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 5ed875784..e1d61bf72 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -46,7 +46,8 @@ Major changes since 3.2.1
Changes since 4.0-alpha1
------------------------
- - renamed CompliantBag to CollectionBag
+ - [COLLECTIONS-468] Renamed CompliantBag to CollectionBag.
+ - [COLLECTIONS-475] Fixed conversion of timeout parameters in "PassiveExpiringMap".
Removed classes
@@ -206,6 +207,7 @@ Changed classes / methods
Fixed Bugs
----------
+ o [COLLECTIONS-475] Fixed conversion of timeout parameters in "PassiveExpiringMap".
o [COLLECTIONS-474] ListOrderedMap#putAll(index, Object, Object) does not throw an exception anymore if the
map contains null values. Additionally added javadoc clarification on the supported bounds
for the index parameter. Thanks to Ning Chen.
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f801a7e3d..19ac684b3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -22,8 +22,11 @@
-
- Exception in ListOrderedMap#putAll if map contains null values.
+
+ Fixed conversion of timeout parameters in "PassiveExpiringMap".
+
+
+ Exception in "ListOrderedMap#putAll" if map contains null values.
Made field "collection" in class "AbstractCollectionDecorator" private and added
diff --git a/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java b/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java
index c6776a70c..2a18e45fc 100644
--- a/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java
+++ b/src/main/java/org/apache/commons/collections4/map/PassiveExpiringMap.java
@@ -121,7 +121,7 @@ public class PassiveExpiringMap
*/
public ConstantTimeToLiveExpirationPolicy(final long timeToLive,
final TimeUnit timeUnit) {
- this(validateAndConvertToMillis(timeToLive, TimeUnit.MILLISECONDS));
+ this(validateAndConvertToMillis(timeToLive, timeUnit));
}
/**
@@ -196,7 +196,7 @@ public class PassiveExpiringMap
if (timeUnit == null) {
throw new IllegalArgumentException("Time unit must not be null");
}
- return timeUnit.convert(timeToLive, TimeUnit.MILLISECONDS);
+ return TimeUnit.MILLISECONDS.convert(timeToLive, timeUnit);
}
/** map used to manage expiration times for the actual map entries. */
diff --git a/src/site/xdoc/release_4_0.xml b/src/site/xdoc/release_4_0.xml
index 5cd313089..0d3676ede 100644
--- a/src/site/xdoc/release_4_0.xml
+++ b/src/site/xdoc/release_4_0.xml
@@ -186,6 +186,7 @@ This release is not source or binary compatible with v3.x.
Bugfixes
+- Fixed conversion of timeout parameters in "PassiveExpiringMap".
- ListOrderedMap#putAll(index, Object, Object) does not throw an exception anymore if the map contains null values. Additionally added javadoc clarification on the supported bounds for the index parameter. Thanks to Ning Chen.
- Improved performance of "AbstractMapBag#containsAll(Collection)" by returning immediately after a difference has been found. Thanks to Adrian Nistor.
- Added additional clarification to javadoc of interface "Put" wrt return type of "put(Object, Object)" method. Thanks to Matt Benson, sebb.
diff --git a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java
index 70a07b03d..77d9a28fc 100644
--- a/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java
+++ b/src/test/java/org/apache/commons/collections4/map/PassiveExpiringMapTest.java
@@ -225,4 +225,28 @@ public class PassiveExpiringMapTest extends AbstractMapTest {
m.put("a", "b");
assertNull(m.get("a"));
}
+
+ public void testExpiration() {
+ validateExpiration(new PassiveExpiringMap(500), 500);
+ validateExpiration(new PassiveExpiringMap(1000), 1000);
+ validateExpiration(new PassiveExpiringMap(
+ new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy(500)), 500);
+ validateExpiration(new PassiveExpiringMap(
+ new PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy(1, TimeUnit.SECONDS)), 1000);
+ }
+
+ private void validateExpiration(final Map map, long timeout) {
+ map.put("a", "b");
+
+ assertNotNull(map.get("a"));
+
+ try {
+ Thread.sleep(2 * timeout);
+ } catch (InterruptedException e) {
+ fail();
+ }
+
+ assertNull(map.get("a"));
+ }
+
}