Skip to content

Conversation

@ekravchenko
Copy link

Hi guys,

This pull request is my attempt to fix Issue# 125 that I logged today. Please take a look at Issue#125 first. I created a sample application with unit tests that better descripes the problem.

While attempting to fix Issue#125 I ran through the following steps:

  1. Create 2 CacheKey object and fill it with 'similar' arrays (same content but different objects);
  2. Equals for CacheKeys should return 'true';
  3. Due to a very broken arrays equals CacheKeys equals will not work as expected;
  4. Please see test failing. (Travis CI build failed after I added that test);
  5. Arrays can't be compared using Object.equals they are very broken when it comes to equals (rather Arrays.equals). So to implement equals in CacheKey properly we need to check if Object is array or not. Apache commons did a great job to nail that problem down;
  6. I added EqualsBuilder and HashCodeBuilder to CacheKey. That fixed test that failed;
  7. When a new jar with updated CacheKey.equals is used Issues#125 seems to fade away.

Hope I understand things right and didn't mess code alot. Please let me know if this pull request makes sense.

Thanks,
YK

This leads to a serious problem that I'm going to log in Issues list

Changed hashCode and equals to use apache.commons HashCodeBuilder and
EqualsBuilder. That fixes problem with arrays. Test
'CacheKeyTest.shouldTestCacheKeysWithBinaryArrays' becomes green after
this change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants