Skip to content

Commit

Permalink
Fix immutable list for Mqttv5MDChAdapter.subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
artembilan committed Jan 30, 2024
1 parent 19ad0dc commit 25874b3
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package org.springframework.integration.mqtt.inbound;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
Expand Down Expand Up @@ -114,7 +116,8 @@ public class Mqttv5PahoMessageDrivenChannelAdapter
*/
public Mqttv5PahoMessageDrivenChannelAdapter(String url, String clientId, MqttSubscription... mqttSubscriptions) {
this(url, clientId, Arrays.stream(mqttSubscriptions).map(MqttSubscription::getTopic).toArray(String[]::new));
this.subscriptions = Arrays.asList(mqttSubscriptions);
this.subscriptions = new ArrayList<>();
Collections.addAll(this.subscriptions, mqttSubscriptions);
}

public Mqttv5PahoMessageDrivenChannelAdapter(String url, String clientId, String... topic) {
Expand All @@ -137,7 +140,8 @@ public Mqttv5PahoMessageDrivenChannelAdapter(MqttConnectionOptions connectionOpt

this(connectionOptions, clientId,
Arrays.stream(mqttSubscriptions).map(MqttSubscription::getTopic).toArray(String[]::new));
this.subscriptions = List.of(mqttSubscriptions);
this.subscriptions = new ArrayList<>();
Collections.addAll(this.subscriptions, mqttSubscriptions);
}

public Mqttv5PahoMessageDrivenChannelAdapter(MqttConnectionOptions connectionOptions, String clientId,
Expand All @@ -162,7 +166,8 @@ public Mqttv5PahoMessageDrivenChannelAdapter(ClientManager<IMqttAsyncClient, Mqt
MqttSubscription... mqttSubscriptions) {

this(clientManager, Arrays.stream(mqttSubscriptions).map(MqttSubscription::getTopic).toArray(String[]::new));
this.subscriptions = List.of(mqttSubscriptions);
this.subscriptions = new ArrayList<>();
Collections.addAll(this.subscriptions, mqttSubscriptions);
}

/**
Expand Down

0 comments on commit 25874b3

Please sign in to comment.