-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I'm using Repositories from spring-data-redis, and I noticed that some of my tests against data repositories is unstable, sometimes they all passes, sometimes one of them fails. I found that CrudRepository.findAll() returns entities in order which is different from run to run. The problem is caused by unpredictable results ordering from call to smembers. I know that redis's set store do not guarantee ordering, but it must be at least deterministic, i.e. no changes in data -> no changes in order.
The order is changed in lettuce code, where the results are transformed to the byte[] and then they are stored in HashSet<byte[]>. Since byte[] does not care about hashCode, this brings to random position in hashset. The code where this behavior can be observed during debugging: io.lettuce.core.output.ValueSetOutput.
Possible solution: Probably byte[] must be replaced to ByteBuffer, because ByteBuffer has overridden method hashCode (i.e. it will stay the same until there's no changes in the data)