editorconfig: max line length set
max line length warnings removed missing Copyright added useless publics removed unmaintainable Javadoc tags: @author removed helper class warnings removed field default value initialization removed Multiple warnings removed pref: checkstyle warnings removed Checkstyle will fail the build process if it detects violations switch default cases error logger added
This commit is contained in:
@@ -21,15 +21,15 @@ import io.netty.handler.codec.mqtt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MessageBuilder {
|
||||
public final class MessageBuilder {
|
||||
|
||||
public static class PublishBuilder {
|
||||
|
||||
private String topic = null;
|
||||
private boolean retained = false;
|
||||
private String topic;
|
||||
private boolean retained;
|
||||
private MqttQoS qos;
|
||||
private byte[] payload;
|
||||
private int messageId = 0;
|
||||
private int messageId;
|
||||
|
||||
public PublishBuilder topicName(String topic) {
|
||||
this.topic = topic;
|
||||
@@ -67,16 +67,16 @@ public class MessageBuilder {
|
||||
|
||||
private MqttVersion version = MqttVersion.MQTT_3_1_1;
|
||||
private String clientId;
|
||||
private boolean cleanSession = false;
|
||||
private boolean hasUser = false;
|
||||
private boolean hasPassword = false;
|
||||
private boolean cleanSession;
|
||||
private boolean hasUser;
|
||||
private boolean hasPassword;
|
||||
private int keepAliveSecs;
|
||||
private boolean willFlag = false;
|
||||
private boolean willFlag;
|
||||
private MqttQoS willQos = MqttQoS.AT_MOST_ONCE;
|
||||
private String willTopic = null;
|
||||
private String willMessage = null;
|
||||
private String username = null;
|
||||
private String password = null;
|
||||
private String willTopic;
|
||||
private String willMessage;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public ConnectBuilder protocolVersion(MqttVersion version) {
|
||||
this.version = version;
|
||||
@@ -196,7 +196,7 @@ public class MessageBuilder {
|
||||
public static class UnsubscribeBuilder {
|
||||
|
||||
private List<String> topicFilters = new ArrayList<>();
|
||||
private int messageId = 0;
|
||||
private int messageId;
|
||||
|
||||
public UnsubscribeBuilder addTopicFilter(String topic) {
|
||||
topicFilters.add(topic);
|
||||
@@ -236,4 +236,7 @@ public class MessageBuilder {
|
||||
public static UnsubscribeBuilder unsubscribe() {
|
||||
return new UnsubscribeBuilder();
|
||||
}
|
||||
|
||||
private MessageBuilder() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +50,6 @@ import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import static io.moquette.BrokerConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrea
|
||||
*/
|
||||
public class NettyAcceptor implements ServerAcceptor {
|
||||
|
||||
private static final String MQTT_SUBPROTOCOL_CSV_LIST = "mqtt, mqttv3.1, mqttv3.1.1";
|
||||
|
||||
@@ -25,10 +25,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import static io.netty.handler.codec.mqtt.MqttQoS.AT_MOST_ONCE;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrea
|
||||
*/
|
||||
@Sharable
|
||||
public class NettyMQTTHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
@@ -83,6 +79,9 @@ public class NettyMQTTHandler extends ChannelInboundHandlerAdapter {
|
||||
MqttMessage pingResp = new MqttMessage(pingHeader);
|
||||
ctx.writeAndFlush(pingResp);
|
||||
break;
|
||||
default:
|
||||
LOG.error("Unkonwn MessageType:{}", messageType);
|
||||
break;
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
LOG.error("Exception was caught while processing MQTT message, " + ex.getCause(), ex);
|
||||
|
||||
@@ -24,10 +24,8 @@ import io.netty.util.AttributeKey;
|
||||
|
||||
/**
|
||||
* Some Netty's channels utilities.
|
||||
*
|
||||
* @author andrea
|
||||
*/
|
||||
public class NettyUtils {
|
||||
public final class NettyUtils {
|
||||
|
||||
public static final String ATTR_USERNAME = "username";
|
||||
public static final String ATTR_SESSION_STOLEN = "sessionStolen";
|
||||
@@ -70,4 +68,7 @@ public class NettyUtils {
|
||||
public static String userName(Channel channel) {
|
||||
return (String) channel.attr(NettyUtils.ATTR_KEY_USERNAME).get();
|
||||
}
|
||||
|
||||
private NettyUtils() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ package io.moquette.server.netty.metrics;
|
||||
|
||||
public class BytesMetrics {
|
||||
|
||||
private long m_readBytes = 0;
|
||||
private long m_wroteBytes = 0;
|
||||
private long m_readBytes;
|
||||
private long m_wroteBytes;
|
||||
|
||||
void incrementRead(long numBytes) {
|
||||
m_readBytes += numBytes;
|
||||
|
||||
@@ -26,10 +26,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import static io.moquette.spi.impl.Utils.messageId;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrea
|
||||
*/
|
||||
@Sharable
|
||||
public class MQTTMessageLogger extends ChannelDuplexHandler {
|
||||
|
||||
@@ -80,6 +76,9 @@ public class MQTTMessageLogger extends ChannelDuplexHandler {
|
||||
case PUBACK:
|
||||
LOG.info("{} PUBACK <{}> packetID <{}>", direction, clientID, messageId(msg));
|
||||
break;
|
||||
default:
|
||||
LOG.error("Unkonwn MessageType:{}", messageType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ package io.moquette.server.netty.metrics;
|
||||
|
||||
public class MessageMetrics {
|
||||
|
||||
private long m_messagesRead = 0;
|
||||
private long m_messageWrote = 0;
|
||||
private long m_messagesRead;
|
||||
private long m_messageWrote;
|
||||
|
||||
void incrementRead(long numMessages) {
|
||||
m_messagesRead += numMessages;
|
||||
|
||||
Reference in New Issue
Block a user