yangxu998 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Behavior of MapMaker.evictionListener() on a ComputingMap #579

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It is not clear from the MapMaker.evictionListener() JavaDoc if the 
evictionListener is called when Map entries are evicted from a map that was 
created using MapMaker.makeComputingMap().

It turns out that the MapEvictionListener is only called when evicting map 
entries that are manually put into the map.
It seems that the MapEvictionListener is never called when evicting map entries 
generated via the Function passed to the makeComputingMap() function.

This may be "working as intended", but in that case it should be documented in 
the evictionListener() method JavaDoc that the listener is NOT called for when 
evicting certain (computed) entries.

I see no reason, however, why the MapEvictionListener should not be called 
whenever ANY map entry is evicted, even those entries computed.

The attached JUnit test case documents the described behavior (evictionListener 
being called on entries put into the map, but not on entries put by a 
ComputedMap Function).

Version of Guava: R08

Original issue reported on code.google.com by morten.h...@gmail.com on 25 Mar 2011 at 2:06

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 25 Mar 2011 at 8:16

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:14

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09