import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
+import org.opendaylight.netconf.api.xml.XmlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
// State variables do not have to by synchronized
// Netty uses always the same (1) thread per pipeline
// We use instance of this per pipeline
- private final List<NetconfMessage> nonHelloMessages = Lists.newArrayList();
+ private final List<NetconfMessage> nonHelloMessages = new ArrayList<>();
private boolean helloReceived = false;
@Override
@VisibleForTesting
public void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out)
- throws IOException, SAXException, NetconfDocumentedException {
+ throws IOException, SAXException {
if (in.readableBytes() == 0) {
LOG.debug("No more content in incoming buffer.");
return;
final NetconfMessage message = getNetconfMessage(additionalHeader, doc);
if (message instanceof NetconfHelloMessage) {
- Preconditions.checkState(helloReceived == false,
+ Preconditions.checkState(!helloReceived,
"Multiple hello messages received, unexpected hello: %s", message);
out.add(message);
helloReceived = true;
}
}
- private static NetconfMessage getNetconfMessage(final String additionalHeader, final Document doc)
- throws NetconfDocumentedException {
+ private static NetconfMessage getNetconfMessage(final String additionalHeader, final Document doc) {
NetconfMessage msg = new NetconfMessage(doc);
if (NetconfHelloMessage.isHelloMessage(msg)) {
if (additionalHeader != null) {