Sonar fixes

Hidden fields, `o.s.i.a*` through `o.s.i.j*`.
This commit is contained in:
Gary Russell
2019-01-08 15:03:00 -05:00
committed by Artem Bilan
parent 6eeec50b4a
commit e40cfe101e
53 changed files with 486 additions and 467 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -157,20 +157,19 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
if (this.usingNio) {
if (isServer()) {
TcpNioServerConnectionFactory connectionFactory = new TcpNioServerConnectionFactory(this.port);
this.setCommonAttributes(connectionFactory);
this.setServerAttributes(connectionFactory);
connectionFactory.setUsingDirectBuffers(this.usingDirectBuffers);
connectionFactory.setTcpNioConnectionSupport(this.obtainNioConnectionSupport());
this.connectionFactory = connectionFactory;
TcpNioServerConnectionFactory factory = new TcpNioServerConnectionFactory(this.port);
this.setCommonAttributes(factory);
this.setServerAttributes(factory);
factory.setUsingDirectBuffers(this.usingDirectBuffers);
factory.setTcpNioConnectionSupport(this.obtainNioConnectionSupport());
this.connectionFactory = factory;
}
else {
TcpNioClientConnectionFactory connectionFactory = new TcpNioClientConnectionFactory(
this.host, this.port);
this.setCommonAttributes(connectionFactory);
connectionFactory.setUsingDirectBuffers(this.usingDirectBuffers);
connectionFactory.setTcpNioConnectionSupport(this.obtainNioConnectionSupport());
this.connectionFactory = connectionFactory;
TcpNioClientConnectionFactory factory = new TcpNioClientConnectionFactory(this.host, this.port);
this.setCommonAttributes(factory);
factory.setUsingDirectBuffers(this.usingDirectBuffers);
factory.setTcpNioConnectionSupport(this.obtainNioConnectionSupport());
this.connectionFactory = factory;
}
if (this.sslHandshakeTimeout != null) {
this.connectionFactory.setSslHandshakeTimeout(this.sslHandshakeTimeout);
@@ -178,20 +177,20 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
else {
if (isServer()) {
TcpNetServerConnectionFactory connectionFactory = new TcpNetServerConnectionFactory(this.port);
this.setCommonAttributes(connectionFactory);
this.setServerAttributes(connectionFactory);
connectionFactory.setTcpSocketFactorySupport(this.obtainSocketFactorySupport());
connectionFactory.setTcpNetConnectionSupport(this.obtainNetConnectionSupport());
this.connectionFactory = connectionFactory;
TcpNetServerConnectionFactory factory = new TcpNetServerConnectionFactory(this.port);
this.setCommonAttributes(factory);
this.setServerAttributes(factory);
factory.setTcpSocketFactorySupport(this.obtainSocketFactorySupport());
factory.setTcpNetConnectionSupport(this.obtainNetConnectionSupport());
this.connectionFactory = factory;
}
else {
TcpNetClientConnectionFactory connectionFactory = new TcpNetClientConnectionFactory(
TcpNetClientConnectionFactory factory = new TcpNetClientConnectionFactory(
this.host, this.port);
this.setCommonAttributes(connectionFactory);
connectionFactory.setTcpSocketFactorySupport(this.obtainSocketFactorySupport());
connectionFactory.setTcpNetConnectionSupport(this.obtainNetConnectionSupport());
this.connectionFactory = connectionFactory;
this.setCommonAttributes(factory);
factory.setTcpSocketFactorySupport(this.obtainSocketFactorySupport());
factory.setTcpNetConnectionSupport(this.obtainNetConnectionSupport());
this.connectionFactory = factory;
}
}
return this.connectionFactory;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@ public abstract class AbstractClientConnectionFactory extends AbstractConnection
protected TcpConnectionSupport obtainConnection() throws Exception {
if (!this.isSingleUse()) {
TcpConnectionSupport connection = this.obtainSharedConnection();
TcpConnectionSupport connection = obtainSharedConnection();
if (connection != null) {
return connection;
}
@@ -84,9 +84,9 @@ public abstract class AbstractClientConnectionFactory extends AbstractConnection
protected final TcpConnectionSupport obtainSharedConnection() throws InterruptedException {
this.theConnectionLock.readLock().lockInterruptibly();
try {
TcpConnectionSupport theConnection = this.getTheConnection();
if (theConnection != null && theConnection.isOpen()) {
return theConnection;
TcpConnectionSupport connection = this.getTheConnection();
if (connection != null && connection.isOpen()) {
return connection;
}
}
finally {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,11 +63,11 @@ public class DefaultTcpNetConnectionSupport extends AbstractTcpConnectionSupport
@Override
protected InputStream inputStream() throws IOException {
InputStream wrapped = super.inputStream();
InputStream wrappedStream = super.inputStream();
// It shouldn't be possible for the wrapped stream to change but, just in case...
if (this.pushbackStream == null || wrapped != this.wrapped) {
this.pushbackStream = new PushbackInputStream(wrapped, this.pushbackBufferSize);
this.wrapped = wrapped;
if (this.pushbackStream == null || !wrappedStream.equals(this.wrapped)) {
this.pushbackStream = new PushbackInputStream(wrappedStream, this.pushbackBufferSize);
this.wrapped = wrappedStream;
}
return this.pushbackStream;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,11 +70,11 @@ public class DefaultTcpNioConnectionSupport extends AbstractTcpConnectionSupport
@Override
protected InputStream inputStream() {
InputStream wrapped = super.inputStream();
InputStream wrappedStream = super.inputStream();
// It shouldn't be possible for the wrapped stream to change but, just in case...
if (this.pushbackStream == null || wrapped != this.wrapped) {
this.pushbackStream = new PushbackInputStream(wrapped, this.pushbackBufferSize);
this.wrapped = wrapped;
if (this.pushbackStream == null || !wrappedStream.equals(this.wrapped)) {
this.pushbackStream = new PushbackInputStream(wrappedStream, this.pushbackBufferSize);
this.wrapped = wrappedStream;
}
return this.pushbackStream;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -128,11 +128,11 @@ public class DefaultTcpNioSSLConnectionSupport extends AbstractTcpConnectionSupp
@Override
protected InputStream inputStream() {
InputStream wrapped = super.inputStream();
InputStream wrappedStream = super.inputStream();
// It shouldn't be possible for the wrapped stream to change but, just in case...
if (this.pushbackStream == null || wrapped != this.wrapped) {
this.pushbackStream = new PushbackInputStream(wrapped, this.pushbackBufferSize);
this.wrapped = wrapped;
if (this.pushbackStream == null || !wrappedStream.equals(this.wrapped)) {
this.pushbackStream = new PushbackInputStream(wrappedStream, this.pushbackBufferSize);
this.wrapped = wrappedStream;
}
return this.pushbackStream;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,9 +63,9 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto
@Override
public int getPort() {
int port = super.getPort();
ServerSocket serverSocket = this.serverSocket;
if (port == 0 && serverSocket != null) {
port = serverSocket.getLocalPort();
ServerSocket socket = this.serverSocket;
if (port == 0 && socket != null) {
port = socket.getLocalPort();
}
return port;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,10 +71,10 @@ public class TcpNioServerConnectionFactory extends AbstractServerConnectionFacto
@Override
public int getPort() {
int port = super.getPort();
ServerSocketChannel serverChannel = this.serverChannel;
if (port == 0 && serverChannel != null) {
ServerSocketChannel channel = this.serverChannel;
if (port == 0 && channel != null) {
try {
SocketAddress address = serverChannel.getLocalAddress();
SocketAddress address = channel.getLocalAddress();
if (address instanceof InetSocketAddress) {
port = ((InetSocketAddress) address).getPort();
}
@@ -126,18 +126,18 @@ public class TcpNioServerConnectionFactory extends AbstractServerConnectionFacto
if (logger.isInfoEnabled()) {
logger.info(this + " Listening");
}
final Selector selector = Selector.open();
final Selector theSelector = Selector.open();
if (this.serverChannel == null) {
if (logger.isDebugEnabled()) {
logger.debug(this + " stopped before registering the server channel");
}
}
else {
this.serverChannel.register(selector, SelectionKey.OP_ACCEPT);
this.serverChannel.register(theSelector, SelectionKey.OP_ACCEPT);
setListening(true);
publishServerListeningEvent(getPort());
this.selector = selector;
doSelect(this.serverChannel, selector);
this.selector = theSelector;
doSelect(this.serverChannel, theSelector);
}
}
catch (IOException e) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -218,10 +218,9 @@ public class UnicastReceivingChannelAdapter extends AbstractInternetProtocolRece
}
protected DatagramPacket receive() throws Exception {
DatagramSocket socket = this.getSocket();
final byte[] buffer = new byte[this.getReceiveBufferSize()];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
getSocket().receive(packet);
return packet;
}
@@ -240,18 +239,18 @@ public class UnicastReceivingChannelAdapter extends AbstractInternetProtocolRece
public synchronized DatagramSocket getSocket() {
if (this.socket == null) {
try {
DatagramSocket socket = null;
DatagramSocket datagramSocket = null;
String localAddress = this.getLocalAddress();
int port = super.getPort();
if (localAddress == null) {
socket = port == 0 ? new DatagramSocket() : new DatagramSocket(port);
datagramSocket = port == 0 ? new DatagramSocket() : new DatagramSocket(port);
}
else {
InetAddress whichNic = InetAddress.getByName(localAddress);
socket = new DatagramSocket(new InetSocketAddress(whichNic, port));
datagramSocket = new DatagramSocket(new InetSocketAddress(whichNic, port));
}
setSocketAttributes(socket);
this.socket = socket;
setSocketAttributes(datagramSocket);
this.socket = datagramSocket;
}
catch (IOException e) {
throw new MessagingException("failed to create DatagramSocket", e);
@@ -279,9 +278,9 @@ public class UnicastReceivingChannelAdapter extends AbstractInternetProtocolRece
protected void doStop() {
super.doStop();
try {
DatagramSocket socket = this.socket;
DatagramSocket datagramSocket = this.socket;
this.socket = null;
socket.close();
datagramSocket.close();
}
catch (Exception e) {
// ignore

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2018 the original author or authors.
* Copyright 2001-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -266,13 +266,13 @@ public class UnicastSendingMessageHandler extends
}
String messageId = id.toString();
try {
boolean waitForAck = this.waitForAck;
if (waitForAck) {
boolean waitAck = this.waitForAck;
if (waitAck) {
countdownLatch = new CountDownLatch(this.ackCounter);
this.ackControl.put(messageId, countdownLatch);
}
convertAndSend(message);
if (waitForAck) {
if (waitAck) {
try {
if (!countdownLatch.await(this.ackTimeout, TimeUnit.MILLISECONDS)) {
throw new MessagingException(message, "Failed to receive UDP Ack in "
@@ -322,12 +322,12 @@ public class UnicastSendingMessageHandler extends
}
protected void convertAndSend(Message<?> message) throws Exception {
DatagramSocket socket;
DatagramSocket datagramSocket;
if (this.socketExpression != null) {
socket = this.socketExpression.getValue(this.evaluationContext, message, DatagramSocket.class);
datagramSocket = this.socketExpression.getValue(this.evaluationContext, message, DatagramSocket.class);
}
else {
socket = getSocket();
datagramSocket = getSocket();
}
SocketAddress destinationAddress;
if (this.destinationExpression != null) {
@@ -353,7 +353,7 @@ public class UnicastSendingMessageHandler extends
DatagramPacket packet = this.mapper.fromMessage(message);
if (packet != null) {
packet.setSocketAddress(destinationAddress);
socket.send(packet);
datagramSocket.send(packet);
if (logger.isDebugEnabled()) {
logger.debug("Sent packet for message " + message + " to " + packet.getSocketAddress());
}
@@ -463,9 +463,9 @@ public class UnicastSendingMessageHandler extends
* @return the ackPort
*/
public int getAckPort() {
DatagramSocket socket = this.socket;
if (this.ackPort == 0 && socket != null) {
return socket.getLocalPort();
DatagramSocket datagramSocket = this.socket;
if (this.ackPort == 0 && datagramSocket != null) {
return datagramSocket.getLocalPort();
}
else {
return this.ackPort;