File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed
main/java/redis/clients/jedis
test/java/redis/clients/jedis/tests Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 66
77import redis .clients .jedis .commands .ProtocolCommand ;
88import redis .clients .jedis .exceptions .JedisAskDataException ;
9+ import redis .clients .jedis .exceptions .JedisBusyException ;
910import redis .clients .jedis .exceptions .JedisClusterException ;
1011import redis .clients .jedis .exceptions .JedisConnectionException ;
1112import redis .clients .jedis .exceptions .JedisDataException ;
@@ -19,6 +20,8 @@ public final class Protocol {
1920 private static final String ASK_RESPONSE = "ASK" ;
2021 private static final String MOVED_RESPONSE = "MOVED" ;
2122 private static final String CLUSTERDOWN_RESPONSE = "CLUSTERDOWN" ;
23+ private static final String BUSY_RESPONSE = "BUSY" ;
24+
2225 public static final String DEFAULT_HOST = "localhost" ;
2326 public static final int DEFAULT_PORT = 6379 ;
2427 public static final int DEFAULT_SENTINEL_PORT = 26379 ;
@@ -114,6 +117,8 @@ private static void processError(final RedisInputStream is) {
114117 Integer .valueOf (askInfo [2 ])), Integer .valueOf (askInfo [0 ]));
115118 } else if (message .startsWith (CLUSTERDOWN_RESPONSE )) {
116119 throw new JedisClusterException (message );
120+ } else if (message .startsWith (BUSY_RESPONSE )) {
121+ throw new JedisBusyException (message );
117122 }
118123 throw new JedisDataException (message );
119124 }
Original file line number Diff line number Diff line change 1+ package redis .clients .jedis .exceptions ;
2+
3+ public class JedisBusyException extends JedisDataException {
4+
5+ private static final long serialVersionUID = 3992655220229243478L ;
6+
7+ public JedisBusyException (final String message ) {
8+ super (message );
9+ }
10+
11+ public JedisBusyException (final Throwable cause ) {
12+ super (cause );
13+ }
14+
15+ public JedisBusyException (final String message , final Throwable cause ) {
16+ super (message , cause );
17+ }
18+
19+ }
Original file line number Diff line number Diff line change 1313import org .junit .Test ;
1414
1515import redis .clients .jedis .Protocol ;
16+ import redis .clients .jedis .exceptions .JedisBusyException ;
1617import redis .clients .util .RedisInputStream ;
1718import redis .clients .util .RedisOutputStream ;
1819import redis .clients .util .SafeEncoder ;
@@ -119,4 +120,17 @@ public void nullMultiBulkReply() {
119120 List <String > response = (List <String >) Protocol .read (new RedisInputStream (is ));
120121 assertNull (response );
121122 }
122- }
123+
124+ @ Test
125+ public void busyReply () {
126+ final String busyMessage = "BUSY Redis is busy running a script." ;
127+ final InputStream is = new ByteArrayInputStream (('-' + busyMessage + "\r \n " ).getBytes ());
128+ try {
129+ Protocol .read (new RedisInputStream (is ));
130+ } catch (final JedisBusyException e ) {
131+ assertEquals (busyMessage , e .getMessage ());
132+ return ;
133+ }
134+ fail ("Expected a JedisBusyException to be thrown." );
135+ }
136+ }
You can’t perform that action at this time.
0 commit comments