Remove remaining deprecated MQTT transport code (#1671)

This removes the remaining deprecated MQTT transport code which was not part of #1668.

Related to #1408

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2020-09-24 19:36:11 +02:00 committed by GitHub
parent 245a692705
commit 369e678a63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 157 deletions

View File

@ -12,7 +12,6 @@
*/
package org.openhab.core.io.transport.mqtt;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -95,8 +94,6 @@ public class MqttBrokerConnection {
/// Configuration variables
private int qos = DEFAULT_QOS;
@Deprecated
private boolean retain = false;
private @Nullable MqttWillAndTestament lastWill;
protected @Nullable AbstractReconnectStrategy reconnectStrategy;
private int keepAliveInterval = DEFAULT_KEEPALIVE_INTERVAL;
@ -117,7 +114,6 @@ public class MqttBrokerConnection {
* The callback will interact with the {@link AbstractReconnectStrategy} as well as inform registered
* {@link MqttConnectionObserver}s.
*/
@NonNullByDefault
public class ConnectionCallback implements MqttClientConnectedListener, MqttClientDisconnectedListener {
private final MqttBrokerConnection connection;
private final Runnable cancelTimeoutFuture;
@ -201,25 +197,6 @@ public class MqttBrokerConnection {
this(Protocol.TCP, MqttVersion.V3, host, port, secure, clientId);
}
/**
* Create a new MQTT3 client connection to a server with the given protocol, mqtt client version, host and port.
*
* @param protocol The transport protocol
* @param host A host name or address
* @param port A port or null to select the default port for a secure or insecure connection
* @param secure A secure connection
* @param clientId Client id. Each client on a MQTT server has a unique client id. Sometimes client ids are
* used for access restriction implementations.
* If none is specified, a default is generated. The client id cannot be longer than 65535
* characters.
* @throws IllegalArgumentException If the client id or port is not valid.
*/
@Deprecated
public MqttBrokerConnection(Protocol protocol, String host, @Nullable Integer port, boolean secure,
@Nullable String clientId) {
this(protocol, MqttVersion.V3, host, port, secure, clientId);
}
/**
* Create a new MQTT client connection to a server with the given protocol, host and port.
*
@ -388,27 +365,6 @@ public class MqttBrokerConnection {
this.qos = qos;
}
/**
* use retain flags on message publish instead
*
* @return true if newly messages sent to the broker should be retained by the broker.
*/
@Deprecated
public boolean isRetain() {
return retain;
}
/**
* Set whether newly published messages should be retained by the broker.
* use retain flags on message publish instead
*
* @param retain true to retain.
*/
@Deprecated
public void setRetain(boolean retain) {
this.retain = retain;
}
/**
* Return the last will object or null if there is none.
*/
@ -444,23 +400,6 @@ public class MqttBrokerConnection {
this.lastWill = lastWill;
}
/**
* Sets the path for the persistence storage.
*
* A persistence mechanism is necessary to enable reliable messaging.
* For messages sent at qualities of service (QoS) 1 or 2 to be reliably delivered, messages must be stored (on both
* the client and server) until the delivery of the message is complete.
* If messages are not safely stored when being delivered then a failure in the client or server can result in lost
* messages.
* A file persistence storage is used that uses the given path. If the path does not exist it will be created on
* runtime (if possible). If it is set to {@code null} a implementation specific default path is used.
*
* @param persistencePath the path that should be used to store persistent data
*/
@Deprecated
public void setPersistencePath(final @Nullable Path persistencePath) {
}
/**
* Get client id to use when connecting to the broker.
*
@ -800,57 +739,6 @@ public class MqttBrokerConnection {
return future.thenApply(this::finalizeStopAfterDisconnect);
}
/**
* Publish a message to the broker.
*
* @param topic The topic
* @param payload The message payload
* @param listener A listener to be notified of success or failure of the delivery.
*/
@Deprecated
public void publish(String topic, byte[] payload, MqttActionCallback listener) {
publish(topic, payload, getQos(), isRetain(), listener);
}
/**
* Publish a message to the broker with the given QoS and retained flag.
*
* @param topic The topic
* @param payload The message payload
* @param qos The quality of service for this message
* @param retain Set to true to retain the message on the broker
* @param listener A listener to be notified of success or failure of the delivery.
*/
@Deprecated
public void publish(String topic, byte[] payload, int qos, boolean retain, MqttActionCallback listener) {
final MqttAsyncClientWrapper client = this.client;
if (client == null) {
listener.onFailure(topic, new MqttException(new Throwable()));
return;
}
client.publish(topic, payload, retain, qos).whenComplete((m, t) -> {
if (t != null) {
listener.onFailure(topic, new MqttException(t));
} else {
listener.onSuccess(topic);
}
});
logger.debug("Publishing message to topic '{}'", topic);
}
/**
* Publish a message to the broker.
*
* @param topic The topic
* @param payload The message payload
* @return Returns a future that completes with a result of true if the publishing succeeded and completes
* exceptionally on an error or with a result of false if no broker connection is established.
*/
public CompletableFuture<Boolean> publish(String topic, byte[] payload) {
return publish(topic, payload, getQos(), isRetain());
}
/**
* Publish a message to the broker with the given QoS and retained flag.
*

View File

@ -34,8 +34,6 @@ public class MqttBrokerConnectionConfig {
public @Nullable String clientID;
// MQTT parameters
public Integer qos = MqttBrokerConnection.DEFAULT_QOS;
@Deprecated
public Boolean retainMessages = false;
/** Keepalive in seconds */
public @Nullable Integer keepAlive;
// Last will parameters

View File

@ -23,21 +23,8 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
@NonNullByDefault
public class MqttException extends Exception {
private static final long serialVersionUID = 301L;
private int reasonCode;
private Throwable cause;
/**
* Constructs a new <code>MqttException</code> with the specified code
* as the underlying reason.
*
* @param reasonCode the reason code for the exception.
*/
@Deprecated
public MqttException(int reasonCode) {
this.cause = new Exception();
this.reasonCode = reasonCode;
}
/**
* Constructs a new <code>MqttException</code> with the specified reason
*
@ -45,7 +32,6 @@ public class MqttException extends Exception {
*/
public MqttException(String reason) {
this.cause = new Exception("reason");
this.reasonCode = Integer.MIN_VALUE;
}
/**
@ -55,33 +41,9 @@ public class MqttException extends Exception {
* @param cause the underlying cause of the exception.
*/
public MqttException(Throwable cause) {
this.reasonCode = Integer.MIN_VALUE;
this.cause = cause;
}
/**
* Constructs a new <code>MqttException</code> with the specified
* <code>Throwable</code> as the underlying reason.
*
* @param reason the reason code for the exception.
* @param cause the underlying cause of the exception.
*/
@Deprecated
public MqttException(int reason, Throwable cause) {
this.reasonCode = reason;
this.cause = cause;
}
/**
* Returns the reason code for this exception.
*
* @return the code representing the reason for this exception.
*/
@Deprecated
public int getReasonCode() {
return reasonCode;
}
/**
* Returns the underlying cause of this exception, if available.
*

View File

@ -104,7 +104,6 @@ public class MqttServiceImpl implements MqttService {
}
connection.setQos(config.qos.intValue());
connection.setRetain(config.retainMessages);
if (config.lwtTopic != null) {
String topic = config.lwtTopic;
MqttWillAndTestament will = new MqttWillAndTestament(topic,

View File

@ -310,10 +310,6 @@ public class MqttBrokerConnectionTests extends JavaTest {
connection.setKeepAliveInterval(80);
assertEquals(80, connection.getKeepAliveInterval());
assertFalse(connection.isRetain());
connection.setRetain(true);
assertTrue(connection.isRetain());
assertEquals(MqttBrokerConnection.DEFAULT_QOS, connection.getQos());
connection.setQos(2);
assertEquals(2, connection.getQos());