Organize Imports for Checkstyle compliance.
Checkstyle compliance: line length.
Checkstyle compliance: various types of small changes.
Checkstyle compliant Exception handling.
Checkstyle final clean up & enforcement.
Add the fail on violation flag into the pom.xml .
Change-Id: Ib65a129cf1f715c4ba37c70a177eea021090eac6
Signed-off-by: matus.kubica <matus.kubica@pantheon.tech>
</instructions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
</plugins>
</build>
private InetSocketAddress getInetAddress(final String bindingAddress, final String portNumber) {
try {
IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(bindingAddress);
- final InetAddress inetAd = InetAddress.getByName(ipAddress.getIpv4Address() == null ?
- ipAddress.getIpv6Address().getValue() : ipAddress.getIpv4Address().getValue());
+ final InetAddress inetAd = InetAddress.getByName(ipAddress.getIpv4Address() == null
+ ? ipAddress.getIpv6Address().getValue() : ipAddress.getIpv4Address().getValue());
return new InetSocketAddress(inetAd, Integer.valueOf(portNumber));
} catch (final UnknownHostException e) {
throw new IllegalArgumentException("Unable to bind netconf tcp endpoint to address " + bindingAddress, e);
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.netconf.tcp.netty;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class ProxyClientHandler extends ChannelInboundHandlerAdapter {
+ private static final Logger LOG = LoggerFactory.getLogger(ProxyClientHandler.class);
+
+ private final ChannelHandlerContext remoteCtx;
+ private ChannelHandlerContext localCtx;
+
+ ProxyClientHandler(ChannelHandlerContext remoteCtx) {
+ this.remoteCtx = remoteCtx;
+ }
+
+ @Override
+ public void channelActive(ChannelHandlerContext ctx) {
+ checkState(this.localCtx == null);
+ LOG.trace("Client channel active");
+ this.localCtx = ctx;
+ }
+
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg) {
+ LOG.trace("Forwarding message");
+ remoteCtx.write(msg);
+ }
+
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx) {
+ LOG.trace("Flushing remote ctx");
+ remoteCtx.flush();
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+ // Close the connection when an exception is raised.
+ LOG.warn("Unexpected exception from downstream", cause);
+ checkState(this.localCtx.equals(ctx));
+ ctx.close();
+ }
+
+ // called both when local or remote connection dies
+ @Override
+ public void channelInactive(ChannelHandlerContext ctx) {
+ LOG.trace("channelInactive() called, closing remote client ctx");
+ remoteCtx.close();
+ }
+
+}
package org.opendaylight.netconf.tcp.netty;
-import static com.google.common.base.Preconditions.checkState;
-
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
}
}
-class ProxyClientHandler extends ChannelInboundHandlerAdapter {
- private static final Logger LOG = LoggerFactory.getLogger(ProxyClientHandler.class);
-
- private final ChannelHandlerContext remoteCtx;
- private ChannelHandlerContext localCtx;
-
- public ProxyClientHandler(ChannelHandlerContext remoteCtx) {
- this.remoteCtx = remoteCtx;
- }
-
- @Override
- public void channelActive(ChannelHandlerContext ctx) {
- checkState(this.localCtx == null);
- LOG.trace("Client channel active");
- this.localCtx = ctx;
- }
-
- @Override
- public void channelRead(ChannelHandlerContext ctx, Object msg) {
- LOG.trace("Forwarding message");
- remoteCtx.write(msg);
- }
-
- @Override
- public void channelReadComplete(ChannelHandlerContext ctx) {
- LOG.trace("Flushing remote ctx");
- remoteCtx.flush();
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
- // Close the connection when an exception is raised.
- LOG.warn("Unexpected exception from downstream", cause);
- checkState(this.localCtx.equals(ctx));
- ctx.close();
- }
-
- // called both when local or remote connection dies
- @Override
- public void channelInactive(ChannelHandlerContext ctx) {
- LOG.trace("channelInactive() called, closing remote client ctx");
- remoteCtx.close();
- }
-
-}
final InetSocketAddress address = netconfConfiguration.getTcpServerAddress();
if (address.getAddress().isAnyLocalAddress()) {
- LOG.warn("Unprotected netconf TCP address is configured to ANY local address. This is a security risk. " +
- "Consider changing tcp-address in netconf.cfg to 127.0.0.1");
+ LOG.warn("Unprotected netconf TCP address is configured to ANY local address. This is a security risk. "
+ + "Consider changing tcp-address in netconf.cfg to 127.0.0.1");
}
LOG.info("Starting TCP netconf server at {}", address);
proxyServer = new ProxyServer(address, NetconfConfiguration.NETCONF_LOCAL_ADDRESS);