[BUG] MqttContext.isValid NPE when client omits password (anonymous/username-only CONNECT)
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
`msg.payload().passwordInBytes()` returns null for any CONNECT whose connect-flags password bit is 0 (valid MQTT client — anonymous or username-only). It is passed into `MqttContext.isValid`, which calls `new String((byte[]) null)` → NPE.
## Location
- `shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/Connect.java:60-62`
- `shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/MqttContext.java:48`
## Impact
Handler thread throws; client never receives a CONNACK and the connection hangs.
## Suggested fix
Null-check `passwordInBytes` in `MqttContext.isValid` (treat null as empty).
## Related existing
Distinct from MQTT-09 (#6748, charset decoding of a non-null password) — this is a null-deref on a missing password.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.