Skip to content

Commit ca99625

Browse files
oliviarlajhpark816
authored andcommitted
FIX: Call correct method for overloaded asyncBopUpsert method
1 parent 83c2b51 commit ca99625

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/main/java/net/spy/memcached/ArcusClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,7 @@ public void gotTrimmedKey(String key, Object bkey) {
19171917
public CollectionFuture<Boolean> asyncBopUpsert(String key, long bkey,
19181918
byte[] elementFlag, Object value,
19191919
CollectionAttributes attributesForCreate) {
1920-
return asyncBopInsert(key, bkey, elementFlag, value, attributesForCreate, collectionTranscoder);
1920+
return asyncBopUpsert(key, bkey, elementFlag, value, attributesForCreate, collectionTranscoder);
19211921
}
19221922

19231923
@Override

src/test/manual/net/spy/memcached/collection/btree/BopUpsertTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616
*/
1717
package net.spy.memcached.collection.btree;
1818

19+
import java.util.Map;
20+
1921
import net.spy.memcached.collection.BaseIntegrationTest;
2022
import net.spy.memcached.collection.CollectionAttributes;
23+
import net.spy.memcached.collection.Element;
24+
import net.spy.memcached.internal.CollectionFuture;
2125

2226
import org.junit.jupiter.api.AfterEach;
2327
import org.junit.jupiter.api.BeforeEach;
2428
import org.junit.jupiter.api.Test;
2529

30+
import static org.junit.jupiter.api.Assertions.assertEquals;
2631
import static org.junit.jupiter.api.Assertions.assertNull;
2732
import static org.junit.jupiter.api.Assertions.assertTrue;
2833
import static org.junit.jupiter.api.Assertions.fail;
@@ -58,4 +63,25 @@ void testUpsertNotExistsKey() {
5863
fail(e.getMessage());
5964
}
6065
}
66+
67+
@Test
68+
void upsertExistingElement() throws Exception {
69+
// given
70+
CollectionFuture<Boolean> future
71+
= mc.asyncBopUpsert(KEY, BKEY, null, "INITIAL_VALUE", new CollectionAttributes());
72+
boolean result = future.get();
73+
assertTrue(result);
74+
75+
// when
76+
future = mc.asyncBopUpsert(KEY, BKEY, null, "UPDATED_VALUE", null);
77+
result = future.get();
78+
79+
// then
80+
assertTrue(result);
81+
CollectionFuture<Map<Long, Element<Object>>> futureToGet
82+
= mc.asyncBopGet(KEY, BKEY, null, false, false);
83+
Map<Long, Element<Object>> elements = futureToGet.get();
84+
assertTrue(elements.containsKey(BKEY));
85+
assertEquals("UPDATED_VALUE", elements.get(BKEY).getValue());
86+
}
6187
}

0 commit comments

Comments
 (0)