Skip to content

Commit deaa6d2

Browse files
committed
fix(resp): 调整 RESP 解码器对非法数据的处理方式
- 将 Arrays 类中的非法数组大小异常改为返回 false- 将 BulkStrings 类中的非法长度异常改为返回 false - 将 Integers 类中的无效整数值异常改为返回 false - 将 Maps 类中的非法映射大小异常改为返回 false - 降低测试并发客户端数量以提高 GitHub Actions 运行速度 - 更新 README 文件,添加关注微信公众号的信息
1 parent 2d8534a commit deaa6d2

7 files changed

Lines changed: 19 additions & 10 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,10 @@ Pull requests and suggestions are welcome. Please refer to the project [issue tr
196196

197197
## Contact
198198

199-
For questions or suggestions, please submit an issue or contact the project maintainer [三刀](https://github.com/smartdms).
199+
For questions or suggestions, please submit an issue or contact the project maintainer [三刀](https://github.com/smartdms).
200+
201+
## Follow Us
202+
203+
If you are interested in our project, please follow our WeChat official account to get the latest updates and technical sharing.
204+
205+
![WeChat](https://smartboot.tech/wx_dyh.png)

README_zh.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,10 @@ mvn test
196196

197197
## 联系方式
198198

199-
如有问题或建议,请提交 issue 或联系项目维护者 [三刀](https://gitee.com/smartdms)
199+
如有问题或建议,请提交 issue 或联系项目维护者 [三刀](https://gitee.com/smartdms)
200+
201+
## 关注我们
202+
203+
如果您对我们的项目感兴趣,欢迎关注我们的微信公众号,获取最新动态和技术分享。
204+
205+
![微信公众号](https://smartboot.tech/wx_dyh.png)

src/main/java/tech/smartboot/redisun/resp/Arrays.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ public boolean decode(ByteBuffer readBuffer) {
8282
value = new ArrayList<>(count);
8383
state = DECODE_STATE_ITEM;
8484
} else {
85-
// 负数键值对个数是非法的
86-
throw new RedisunException("Invalid array size: " + count);
85+
return false;
8786
}
8887
break;
8988
case DECODE_STATE_ITEM:

src/main/java/tech/smartboot/redisun/resp/BulkStrings.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ public boolean decode(ByteBuffer readBuffer) {
7979
out = new ByteArrayOutputStream(length);
8080
state = DECODE_STATE_VALUE;
8181
} else {
82-
// 负数长度是非法的(除了-1,但那是Null的表示方法,应该使用Nulls类)
83-
throw new RedisunException("Invalid array size: " + length);
82+
return false;
8483
}
8584
break;
8685
case DECODE_STATE_VALUE:

src/main/java/tech/smartboot/redisun/resp/Integers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public boolean decode(ByteBuffer readBuffer) {
8585
value = isNegative ? -v : v;
8686
return true;
8787
}
88-
throw new RedisunException("Invalid int value: " + value);
88+
return false;
8989
default:
9090
throw new RedisunException("数据格式错误");
9191
}

src/main/java/tech/smartboot/redisun/resp/Maps.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ public boolean decode(ByteBuffer readBuffer) {
8989
state = DECODE_STATE_KEY;
9090
break;
9191
} else {
92-
// 负数键值对个数是非法的
93-
throw new RedisunException("Invalid map size: " + count);
92+
return false;
9493
}
9594
case DECODE_STATE_KEY:
9695
// 解析键

src/test/java/tech/smartboot/redisun/bench/Bench.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Bench {
88
// 为了在GitHub Actions环境中更快地运行测试,减少测试数据量
99
protected static final int SET_COUNT = 50000;
1010

11-
protected static final int CONCURRENT_CLIENT_COUNT = Integer.parseInt(System.getProperty("client.count", "1024"));
11+
protected static final int CONCURRENT_CLIENT_COUNT = Integer.parseInt(System.getProperty("client.count", "1"));
1212

1313
protected static final String ADDRESS = "redis://127.0.0.1:6379";
1414
}

0 commit comments

Comments
 (0)