@@ -98,8 +98,6 @@ public class Jedis implements ServerCommands, DatabaseCommands, JedisCommands, J
9898
9999 private static final Logger logger = LoggerFactory .getLogger (Jedis .class );
100100
101- private static final RedisProtocol REDIS_SERVER_DEFAULT_PROTO = RedisProtocol .RESP2 ;
102-
103101 protected final Connection connection ;
104102 private final CommandObjects commandObjects ;
105103 private int db = 0 ;
@@ -132,7 +130,7 @@ private static JedisClientConfig sanitize(JedisClientConfig config) {
132130
133131 public Jedis () {
134132 connection = new Connection ();
135- commandObjects = new CommandObjects (REDIS_SERVER_DEFAULT_PROTO );
133+ commandObjects = new CommandObjects (RedisProtocol . REDIS_SERVER_DEFAULT_PROTO );
136134 }
137135
138136 /**
@@ -146,12 +144,12 @@ public Jedis(final String url) {
146144
147145 public Jedis (final HostAndPort hp ) {
148146 connection = new Connection (hp );
149- commandObjects = new CommandObjects (REDIS_SERVER_DEFAULT_PROTO );
147+ commandObjects = new CommandObjects (RedisProtocol . REDIS_SERVER_DEFAULT_PROTO );
150148 }
151149
152150 public Jedis (final String host , final int port ) {
153151 connection = new Connection (host , port );
154- commandObjects = new CommandObjects (REDIS_SERVER_DEFAULT_PROTO );
152+ commandObjects = new CommandObjects (RedisProtocol . REDIS_SERVER_DEFAULT_PROTO );
155153 }
156154
157155 public Jedis (final String host , final int port , final JedisClientConfig config ) {
@@ -161,8 +159,7 @@ public Jedis(final String host, final int port, final JedisClientConfig config)
161159 public Jedis (final HostAndPort hostPort , final JedisClientConfig config ) {
162160 JedisClientConfig effective = sanitize (config );
163161 connection = new Connection (hostPort , effective );
164- RedisProtocol proto = effective .getRedisProtocol ();
165- commandObjects = new CommandObjects (proto != null ? proto : REDIS_SERVER_DEFAULT_PROTO );
162+ commandObjects = new CommandObjects (RedisProtocol .orServerDefault (effective .getRedisProtocol ()));
166163 }
167164
168165 public Jedis (final String host , final int port , final boolean ssl ) {
@@ -242,7 +239,7 @@ public Jedis(URI uri) {
242239 .password (JedisURIHelper .getPassword (uri )).database (JedisURIHelper .getDBIndex (uri ))
243240 .protocol (JedisURIHelper .getRedisProtocol (uri ))
244241 .ssl (JedisURIHelper .isRedisSSLScheme (uri )).build ());
245- commandObjects = new CommandObjects (REDIS_SERVER_DEFAULT_PROTO );
242+ commandObjects = new CommandObjects (RedisProtocol . REDIS_SERVER_DEFAULT_PROTO );
246243 }
247244
248245 public Jedis (URI uri , final SSLSocketFactory sslSocketFactory ,
@@ -311,25 +308,23 @@ public Jedis(final URI uri, JedisClientConfig config) {
311308 .ssl (JedisURIHelper .isRedisSSLScheme (uri )).sslSocketFactory (effective .getSslSocketFactory ())
312309 .sslParameters (effective .getSslParameters ()).hostnameVerifier (effective .getHostnameVerifier ())
313310 .build ());
314- RedisProtocol proto = effective .getRedisProtocol ();
315- commandObjects = new CommandObjects (proto != null ? proto : REDIS_SERVER_DEFAULT_PROTO );
311+ commandObjects = new CommandObjects (RedisProtocol .orServerDefault (effective .getRedisProtocol ()));
316312 }
317313
318314 public Jedis (final JedisSocketFactory jedisSocketFactory ) {
319315 connection = new Connection (jedisSocketFactory );
320- commandObjects = new CommandObjects (REDIS_SERVER_DEFAULT_PROTO );
316+ commandObjects = new CommandObjects (RedisProtocol . REDIS_SERVER_DEFAULT_PROTO );
321317 }
322318
323319 public Jedis (final JedisSocketFactory jedisSocketFactory , final JedisClientConfig clientConfig ) {
324320 JedisClientConfig effective = sanitize (clientConfig );
325321 connection = new Connection (jedisSocketFactory , effective );
326- RedisProtocol proto = effective .getRedisProtocol ();
327- commandObjects = new CommandObjects (proto != null ? proto : REDIS_SERVER_DEFAULT_PROTO );
322+ commandObjects = new CommandObjects (RedisProtocol .orServerDefault (effective .getRedisProtocol ()));
328323 }
329324
330325 public Jedis (final Connection connection ) {
331326 this .connection = connection ;
332- this .commandObjects = new CommandObjects (REDIS_SERVER_DEFAULT_PROTO );
327+ this .commandObjects = new CommandObjects (RedisProtocol . REDIS_SERVER_DEFAULT_PROTO );
333328 }
334329
335330 @ Override
0 commit comments