Skip to content

Commit c2e611e

Browse files
committed
fix same bug in binary protocol if used in sanitized mode.
1 parent 7367c7f commit c2e611e

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/main/com/schooner/MemCached/BinaryClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,16 +859,16 @@ public Map<String, Object> getMulti(String[] keys, Integer[] hashCodes, boolean
859859
(new NIOLoader(this)).doMulti(asString, cmdMap, keys, ret);
860860

861861
// fix the return array in case we had to rewrite any of the keys
862-
for (int i=0;i<keys.length;++i) {
862+
for (int i = 0; i < keys.length; ++i) {
863863

864-
//if key!=cleanKey and result has cleankey
864+
// if key!=cleanKey and result has cleankey
865865
if (!keys[i].equals(cleanKeys[i]) && ret.containsKey(cleanKeys[i])) {
866866
ret.put(keys[i], ret.get(cleanKeys[i]));
867867
ret.remove(cleanKeys[i]);
868868
}
869869

870870
// backfill missing keys w/ null value
871-
if (!ret.containsKey(cleanKeys[i]))
871+
if (!ret.containsKey(keys[i]))
872872
ret.put(keys[i], null);
873873
}
874874

src/test/com/schooner/MemCached/WhalinScenarioTest.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ public void testGetMultiArray() {
618618
String[] values = new String[10];
619619
for (int i = 0; i < 10; i++) {
620620
keys[i] = "key " + i;
621-
values[i]="value " + i;
621+
values[i] = "value " + i;
622622
mc.set(keys[i], values[i]);
623623
}
624624
Map<String, Object> rValues = mc.getMulti(keys, null, false);
@@ -767,4 +767,25 @@ public void testGetMulti() {
767767
mc.flushAll();
768768
pool.shutDown();
769769
}
770+
771+
public void testGetMultiBin() {
772+
SockIOPool pool = SockIOPool.getInstance();
773+
pool.setServers(hosts);
774+
pool.initialize();
775+
final MemCachedClient mc = new MemCachedClient(true, true);
776+
mc.setSanitizeKeys(true);
777+
String[] keys = new String[10];
778+
String[] values = new String[10];
779+
for (int i = 0; i < 10; i++) {
780+
keys[i] = "key/ " + i;
781+
values[i] = "value " + i;
782+
mc.set(keys[i], values[i]);
783+
}
784+
Map<String, Object> rValues = mc.getMulti(keys);
785+
for (int i = 0; i < 10; i++) {
786+
assertEquals(values[i], rValues.get("key/ " + i));
787+
}
788+
mc.flushAll();
789+
pool.shutDown();
790+
}
770791
}

0 commit comments

Comments
 (0)