From 0b52ffe146e8c9e84883c339ab4097d4bf855f15 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Thu, 17 Feb 2022 18:07:43 +0600 Subject: [PATCH] Configure socket buffer size through system property --- .../java/redis/clients/jedis/util/RedisInputStream.java | 6 +++++- .../java/redis/clients/jedis/util/RedisOutputStream.java | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/redis/clients/jedis/util/RedisInputStream.java b/src/main/java/redis/clients/jedis/util/RedisInputStream.java index edba833db8..bebdb27c07 100644 --- a/src/main/java/redis/clients/jedis/util/RedisInputStream.java +++ b/src/main/java/redis/clients/jedis/util/RedisInputStream.java @@ -22,6 +22,10 @@ */ public class RedisInputStream extends FilterInputStream { + private static final int INPUT_BUFFER_SIZE = Integer.parseInt( + System.getProperty("jedis.bufferSize.input", + System.getProperty("jedis.bufferSize", "8192"))); + protected final byte[] buf; protected int count, limit; @@ -35,7 +39,7 @@ public RedisInputStream(InputStream in, int size) { } public RedisInputStream(InputStream in) { - this(in, 8192); + this(in, INPUT_BUFFER_SIZE); } public byte readByte() throws JedisConnectionException { diff --git a/src/main/java/redis/clients/jedis/util/RedisOutputStream.java b/src/main/java/redis/clients/jedis/util/RedisOutputStream.java index 7c1df721f7..998b288e16 100644 --- a/src/main/java/redis/clients/jedis/util/RedisOutputStream.java +++ b/src/main/java/redis/clients/jedis/util/RedisOutputStream.java @@ -10,6 +10,11 @@ * used outside Jedis */ public final class RedisOutputStream extends FilterOutputStream { + + private static final int OUTPUT_BUFFER_SIZE = Integer.parseInt( + System.getProperty("jedis.bufferSize.output", + System.getProperty("jedis.bufferSize", "8192"))); + protected final byte[] buf; protected int count; @@ -36,7 +41,7 @@ public final class RedisOutputStream extends FilterOutputStream { 't', 'u', 'v', 'w', 'x', 'y', 'z' }; public RedisOutputStream(final OutputStream out) { - this(out, 8192); + this(out, OUTPUT_BUFFER_SIZE); } public RedisOutputStream(final OutputStream out, final int size) {