DATAREDIS-448 - Fix DefaultSetOperations.intersectAndStore not returning command result.

We now properly return the number of elements in the destination set, has always been null so far, for DefaultSetOperations.intersectAndStore.
This commit is contained in:
Christoph Strobl
2016-01-28 07:59:32 +01:00
parent 6111abdcfa
commit e7bfa2f26e
2 changed files with 23 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -105,8 +105,7 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
return execute(new RedisCallback<Long>() {
public Long doInRedis(RedisConnection connection) {
connection.sInterStore(rawDestKey, rawKeys);
return null;
return connection.sInterStore(rawDestKey, rawKeys);
}
}, true);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 - 2014 the original author or authors.
* Copyright 2013 - 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -221,6 +221,26 @@ public class DefaultSetOperationsTests<K, V> {
count++;
}
assertThat(count, is(setOps.size(key)));
}
/**
* @see DATAREDIS-448
*/
@Test
public void intersectAndStoreShouldReturnNumberOfElementsInDestination() {
K sourceKey1 = keyFactory.instance();
K sourceKey2 = keyFactory.instance();
K destinationKey = keyFactory.instance();
V v1 = valueFactory.instance();
V v2 = valueFactory.instance();
V v3 = valueFactory.instance();
V v4 = valueFactory.instance();
setOps.add(sourceKey1, v1, v2, v3);
setOps.add(sourceKey2, v2, v3, v4);
assertThat(setOps.intersectAndStore(sourceKey1, sourceKey2, destinationKey), is(2L));
}
}