Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
EhCache declarative caching hash collision issues Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • EhCache declarative caching hash collision issues

    Hi,

    I am using EhCacheFacade for declarative caching. Recently, I noticed that even the first invocation of some methods were being returned from the cache, without calling the method at all.

    On digging deeper I found that when hashcode() matches for input arguments for a method, the input arguments are assumed to be equal. So, when there is a hash collision on input arguments across different method invocations, the method invocation are assumed to be the same.

    For eg: Lets have a function - int foobar(Foo f, Bar b);
    For two invocations of foobar --
    Invocation 1 - foobar(f1, b1)
    Invocation 2 - foobar(f2, b2)

    If f1.hashcode() == f2.hashcode() and b1.hashcode() == b2.hashcode() [even though f1 not equal to f2, and b1 not equal to b2] - the caching module assumes both invocations are the same. Hence it returns the cached version of Invocation 1 when Invocation 2 happens.

    Has anyone else encountered the above issue? Any reason why the caching module is not taking care of hash collisions, or am I missing something here?

    Thanks.

  • #2
    Noticed it too

    Yes I just noticed this too. Pretty scary. I am looking into replacing HashCodeCacheKeyGenerator with my own implementation.

    Comment

    Working...
    X