Skip to content

Commit ef184b0

Browse files
committed
Merge remote-tracking branch 'github/feature-broker-26' into feature-broker-33
# Conflicts: # src/test/groovy/com/ss/mqtt/broker/test/integration/ConnectSubscribePublishTest.groovy
2 parents f78c65e + b79e1a5 commit ef184b0

File tree

4 files changed

+14
-122
lines changed

4 files changed

+14
-122
lines changed

src/main/java/com/ss/mqtt/broker/model/SubscribeTopicFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public SubscribeTopicFilter(@NotNull TopicFilter topicFilter, @NotNull QoS qos)
5151
}
5252

5353
@Override
54-
public String toString() {
54+
public @NotNull String toString() {
5555
return "SubscribeTopicFilter(" + "topicFilter=" + topicFilter.getRawTopic() + ", qos=" + qos + ", retainHandling=" +
5656
retainHandling + ", noLocal=" + noLocal + ", retainAsPublished=" + retainAsPublished + ')';
5757
}

src/main/java/com/ss/mqtt/broker/network/packet/in/ConnectInPacket.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,9 @@ protected void readVariableHeader(@NotNull MqttConnection connection, @NotNull B
282282
hasUserName = NumberUtils.isSetBit(flags, 7);
283283
hasPassword = NumberUtils.isSetBit(flags, 6);
284284

285-
if (mqttVersion.ordinal() < MqttVersion.MQTT_5.ordinal()) {
286-
287-
// for mqtt < 5 we cannot have password without user
288-
if (!hasUserName && hasPassword) {
289-
throw new ConnectionRejectException(ConnectAckReasonCode.BAD_USER_NAME_OR_PASSWORD);
290-
}
285+
// for mqtt < 5 we cannot have password without user
286+
if (mqttVersion.ordinal() < MqttVersion.MQTT_5.ordinal() && !hasUserName && hasPassword) {
287+
throw new ConnectionRejectException(ConnectAckReasonCode.BAD_USER_NAME_OR_PASSWORD);
291288
}
292289

293290
willFlag = NumberUtils.isSetBit(flags, 2);

src/test/groovy/com/ss/mqtt/broker/test/integration/ConnectSubscribePublishTest.groovy

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class ConnectSubscribePublishTest extends IntegrationSpecification {
4444
received.get().qos == MqttQos.AT_MOST_ONCE
4545
received.get().type == Mqtt3MessageType.PUBLISH
4646
cleanup:
47-
subscriber.disconnect()
48-
publisher.disconnect()
47+
subscriber.disconnect().join()
48+
publisher.disconnect().join()
4949
}
5050

5151
def "publisher should publish message QoS 0 using mqtt 5"() {
@@ -77,8 +77,8 @@ class ConnectSubscribePublishTest extends IntegrationSpecification {
7777
received.get().qos == MqttQos.AT_MOST_ONCE
7878
received.get().type == Mqtt5MessageType.PUBLISH
7979
cleanup:
80-
subscriber.disconnect()
81-
publisher.disconnect()
80+
subscriber.disconnect().join()
81+
publisher.disconnect().join()
8282
}
8383

8484
def "publisher should publish message QoS 1 using mqtt 3.1.1"() {
@@ -110,8 +110,8 @@ class ConnectSubscribePublishTest extends IntegrationSpecification {
110110
received.get().qos == MqttQos.AT_LEAST_ONCE
111111
received.get().type == Mqtt3MessageType.PUBLISH
112112
cleanup:
113-
subscriber.disconnect()
114-
publisher.disconnect()
113+
subscriber.disconnect().join()
114+
publisher.disconnect().join()
115115
}
116116

117117
def "publisher should publish message QoS 1 using mqtt 5"() {
@@ -177,8 +177,8 @@ class ConnectSubscribePublishTest extends IntegrationSpecification {
177177
received.get().qos == MqttQos.EXACTLY_ONCE
178178
received.get().type == Mqtt3MessageType.PUBLISH
179179
cleanup:
180-
subscriber.disconnect()
181-
publisher.disconnect()
180+
subscriber.disconnect().join()
181+
publisher.disconnect().join()
182182
}
183183

184184
def "publisher should publish message QoS 2 using mqtt 5"() {
@@ -211,8 +211,8 @@ class ConnectSubscribePublishTest extends IntegrationSpecification {
211211
received.get().qos == MqttQos.EXACTLY_ONCE
212212
received.get().type == Mqtt5MessageType.PUBLISH
213213
cleanup:
214-
subscriber.disconnect()
215-
publisher.disconnect()
214+
subscriber.disconnect().join()
215+
publisher.disconnect().join()
216216
}
217217

218218
def publish(Mqtt5AsyncClient publisher, String subscriberId, MqttQos qos) {

src/test/groovy/com/ss/mqtt/broker/test/integration/service/PublishRetryServiceTest.groovy

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)