Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
java胎教生
mica-mqtt
提交
c883282f
mica-mqtt
项目概览
java胎教生
/
mica-mqtt
与 Fork 源项目一致
Fork自
mica / mica-mqtt
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
mica-mqtt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c883282f
编写于
8月 13, 2021
作者:
浅梦2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
优化解码异常处理
上级
cde9c6af
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
5 deletion
+25
-5
mica-mqtt-codec/src/main/java/net/dreamlu/iot/mqtt/codec/MqttDecoder.java
...src/main/java/net/dreamlu/iot/mqtt/codec/MqttDecoder.java
+1
-1
mica-mqtt-core/src/main/java/net/dreamlu/iot/mqtt/core/client/MqttClientAioHandler.java
...et/dreamlu/iot/mqtt/core/client/MqttClientAioHandler.java
+12
-2
mica-mqtt-core/src/main/java/net/dreamlu/iot/mqtt/core/server/MqttServerAioHandler.java
...et/dreamlu/iot/mqtt/core/server/MqttServerAioHandler.java
+12
-2
未找到文件。
mica-mqtt-codec/src/main/java/net/dreamlu/iot/mqtt/codec/MqttDecoder.java
浏览文件 @
c883282f
...
...
@@ -80,7 +80,7 @@ public final class MqttDecoder {
Result
<?>
decodedVariableHeader
=
decodeVariableHeader
(
ctx
,
buffer
,
mqttFixedHeader
,
bytesRemainingInVariablePart
);
variableHeader
=
decodedVariableHeader
.
value
;
if
(
bytesRemainingInVariablePart
>
maxBytesInMessage
)
{
throw
new
DecoderException
(
"too large message: "
+
bytesRemainingInVariablePart
+
" bytes
"
);
throw
new
DecoderException
(
"too large message: "
+
bytesRemainingInVariablePart
+
" bytes
but maxBytesInMessage is "
+
maxBytesInMessage
);
}
bytesRemainingInVariablePart
-=
decodedVariableHeader
.
numberOfBytesConsumed
;
}
catch
(
Exception
cause
)
{
...
...
mica-mqtt-core/src/main/java/net/dreamlu/iot/mqtt/core/client/MqttClientAioHandler.java
浏览文件 @
c883282f
...
...
@@ -20,6 +20,8 @@ import net.dreamlu.iot.mqtt.codec.*;
import
org.tio.client.intf.ClientAioHandler
;
import
org.tio.core.ChannelContext
;
import
org.tio.core.TioConfig
;
import
org.tio.core.exception.AioDecodeException
;
import
org.tio.core.exception.TioDecodeException
;
import
org.tio.core.intf.Packet
;
import
java.nio.ByteBuffer
;
...
...
@@ -49,8 +51,16 @@ public class MqttClientAioHandler implements ClientAioHandler {
}
@Override
public
Packet
decode
(
ByteBuffer
buffer
,
int
limit
,
int
position
,
int
readableLength
,
ChannelContext
channelContext
)
{
return
mqttDecoder
.
decode
(
channelContext
,
buffer
,
limit
,
position
,
readableLength
);
public
Packet
decode
(
ByteBuffer
buffer
,
int
limit
,
int
position
,
int
readableLength
,
ChannelContext
context
)
throws
TioDecodeException
{
MqttMessage
message
=
mqttDecoder
.
decode
(
context
,
buffer
,
limit
,
position
,
readableLength
);
if
(
message
==
null
)
{
return
null
;
}
DecoderResult
decoderResult
=
message
.
decoderResult
();
if
(
decoderResult
.
isFailure
()
&&
decoderResult
.
getCause
()
instanceof
DecoderException
)
{
throw
new
AioDecodeException
(
decoderResult
.
getCause
());
}
return
message
;
}
@Override
...
...
mica-mqtt-core/src/main/java/net/dreamlu/iot/mqtt/core/server/MqttServerAioHandler.java
浏览文件 @
c883282f
...
...
@@ -22,6 +22,8 @@ import org.slf4j.LoggerFactory;
import
org.tio.core.ChannelContext
;
import
org.tio.core.Tio
;
import
org.tio.core.TioConfig
;
import
org.tio.core.exception.AioDecodeException
;
import
org.tio.core.exception.TioDecodeException
;
import
org.tio.core.intf.Packet
;
import
org.tio.server.AcceptCompletionHandler
;
import
org.tio.server.intf.ServerAioHandler
;
...
...
@@ -58,8 +60,16 @@ public class MqttServerAioHandler implements ServerAioHandler {
* @return Packet
*/
@Override
public
Packet
decode
(
ByteBuffer
buffer
,
int
limit
,
int
position
,
int
readableLength
,
ChannelContext
context
)
{
return
mqttDecoder
.
decode
(
context
,
buffer
,
limit
,
position
,
readableLength
);
public
Packet
decode
(
ByteBuffer
buffer
,
int
limit
,
int
position
,
int
readableLength
,
ChannelContext
context
)
throws
TioDecodeException
{
MqttMessage
message
=
mqttDecoder
.
decode
(
context
,
buffer
,
limit
,
position
,
readableLength
);
if
(
message
==
null
)
{
return
null
;
}
DecoderResult
decoderResult
=
message
.
decoderResult
();
if
(
decoderResult
.
isFailure
()
&&
decoderResult
.
getCause
()
instanceof
DecoderException
)
{
throw
new
AioDecodeException
(
decoderResult
.
getCause
());
}
return
message
;
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录