Merge branch 'master' into 3.0.0

pull/802/merge
Nikita 8 years ago
commit 7279728b7e

@ -75,7 +75,10 @@ public class RedissonBinaryStream extends RedissonBucket<byte[]> implements RBin
public long skip(long n) throws IOException {
long k = size() - index;
if (n < k) {
k = n < 0 ? 0 : n;
k = n;
if (n < 0) {
k = 0;
}
}
index += k;

@ -2,6 +2,7 @@ package org.redisson;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -71,6 +72,17 @@ public class RedissonBinaryStreamTest extends BaseTest {
}
}
@Test
public void testSkip() throws IOException {
RBinaryStream t = redisson.getBinaryStream("test");
t.set(new byte[] {1, 2, 3, 4, 5, 6});
InputStream is = t.getInputStream();
is.skip(3);
byte[] b = new byte[6];
is.read(b);
assertThat(b).isEqualTo(new byte[] {4, 5, 6, 0, 0, 0});
}
@Test
public void testLimit512by1024() throws IOException, NoSuchAlgorithmException {

Loading…
Cancel
Save