wy471x opened a new pull request, #6983:
URL: https://github.com/apache/shenyu/pull/6983

   Make sure that:
   
   - [X] You have read the [contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide).
   - [X] You submit test cases (unit or integration tests) that back your 
changes.
   - [X] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.
   
   ## Summary
   
   ### Changes:
   1. `MessageType.java` — connection state moved from a per-instance `volatile 
boolean` (dead: `MqttFactory` builds a fresh `MessageType` per inbound message, 
so the state set by `Connect.connect()` never propagated to other handlers) to 
a per-channel `AttributeKey<Boolean>`; `isConnected(Channel)` / 
`setConnected(Channel, boolean)` now read/write the channel attribute.
   2. `Publish.java`, `Unsubscribe.java`, `PingReq.java` — guards inverted to 
`if (!isConnected(ctx.channel()))`; like `Subscribe`, the channel is now closed 
(`FIRE_EXCEPTION_ON_FAILURE`) instead of silently dropping the packet.
   3. `Subscribe.java` — inverted the dead `if (isConnected())` guard.
   4. `Connect.java` — duplicate CONNECT on the same channel is rejected by 
closing the connection without sending a CONNACK ([MQTT-3.1.0-2]).
   
   ### Test Cases:
   1. `ConnectTest` — migrated from Mockito mocks to a real `EmbeddedChannel` 
(per-channel attributes require a real channel); added 
`duplicateConnectIsRejected` (second CONNECT receives no CONNACK and closes the 
channel).
   2. `PublishTest` — added `publishBeforeConnectClosesChannel` and the 
end-to-end `publishAfterConnectOnSameChannelIsAccepted` (real 
`Connect.connect()` followed by `Publish.publish()` on the same channel).
   3. New `PingReqTest` — `pingReqBeforeConnectClosesChannel`, 
`pingReqAfterConnectSendsPingResp`.
   4. New `UnsubscribeTest` — `unsubscribeBeforeConnectClosesChannel`.
   
   ## Verification
   
   - `shenyu-protocol-mqtt` module: 13 tests passed (ConnectTest 5, PublishTest 
5, PingReqTest 2, UnsubscribeTest 1), JDK 21.
   - Checkstyle and RAT (license header) checks passed.
   
   close #6638
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to