codec null handling fixed

pull/243/head
Nikita 10 years ago
parent b42191bfea
commit e9d0c005ab

@ -112,7 +112,11 @@ public class CommandDecoder extends ReplayingDecoder<Void> {
Object result = Long.valueOf(status);
handleResult(data, parts, result);
} else if (code == '$') {
Object result = decoder(data, parts, currentDecoder).decode(readBytes(in));
ByteBuf buf = readBytes(in);
Object result = null;
if (buf != null) {
result = decoder(data, parts, currentDecoder).decode(buf);
}
handleResult(data, parts, result);
} else if (code == '*') {
long size = readLong(in);

@ -27,9 +27,6 @@ public class LongCodec extends StringCodec {
return new Decoder<Object>() {
@Override
public Object decode(ByteBuf buf) {
if (buf == null) {
return null;
}
return Long.valueOf(buf.toString(CharsetUtil.UTF_8));
}
};

@ -29,9 +29,6 @@ public class StringCodec implements Codec {
return new Decoder<Object>() {
@Override
public Object decode(ByteBuf buf) {
if (buf == null) {
return null;
}
return buf.toString(CharsetUtil.UTF_8);
}
};

@ -97,10 +97,6 @@ public class JsonJacksonCodec implements Codec {
@Override
public Object decode(ByteBuf buf) throws IOException {
if (buf == null) {
return null;
}
return mapObjectMapper.readValue(new ByteBufInputStream(buf), Object.class);
}
};

@ -441,6 +441,14 @@ public class RedissonMapTest extends BaseTest {
Assert.assertEquals(3, map.size());
}
@Test
public void testEmptyRemove() {
RMap<Integer, Integer> map = redisson.getMap("simple");
Assert.assertFalse(map.remove(1, 3));
map.put(4, 5);
Assert.assertTrue(map.remove(4, 5));
}
@Test
public void testPutAsync() throws InterruptedException, ExecutionException {
RMap<Integer, Integer> map = redisson.getMap("simple");

Loading…
Cancel
Save