File, FTP, IP Sonar Fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -49,6 +49,7 @@ public interface InboundMessageMapper<T> {
|
||||
* @throws Exception the exception thrown by the underlying mapper implementation
|
||||
* @since 5.0
|
||||
*/
|
||||
@Nullable
|
||||
Message<?> toMessage(T object, @Nullable Map<String, Object> headers) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
|
||||
|
||||
if (this.destinationDirectoryExpression instanceof LiteralExpression) {
|
||||
final File directory =
|
||||
new File(this.destinationDirectoryExpression.getValue(this.evaluationContext, null, String.class));
|
||||
new File(this.destinationDirectoryExpression.getValue(this.evaluationContext, String.class));
|
||||
|
||||
validateDestinationDirectory(directory, this.autoCreateDirectory);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class FtpInboundFileSynchronizer extends AbstractInboundFileSynchronizer<
|
||||
*/
|
||||
public FtpInboundFileSynchronizer(SessionFactory<FTPFile> sessionFactory) {
|
||||
super(sessionFactory);
|
||||
doSetRemoteDirectoryExpression(new LiteralExpression(null));
|
||||
doSetRemoteDirectoryExpression(new LiteralExpression(null)); // NOSONAR - LE can actually handle null ok
|
||||
doSetFilter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "ftpMessageSource"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -21,6 +21,7 @@ import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Abstract class for client connection factories; client connection factories
|
||||
@@ -79,6 +80,7 @@ public abstract class AbstractClientConnectionFactory extends AbstractConnection
|
||||
return obtainNewConnection();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected final TcpConnectionSupport obtainSharedConnection() throws InterruptedException {
|
||||
this.theConnectionLock.readLock().lockInterruptibly();
|
||||
try {
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.springframework.core.serializer.Deserializer;
|
||||
import org.springframework.core.serializer.Serializer;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -610,8 +611,10 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
|
||||
* @param connections Map of connections.
|
||||
* @throws IOException Any IOException.
|
||||
*/
|
||||
protected void processNioSelections(int selectionCount, final Selector selector, ServerSocketChannel server,
|
||||
protected void processNioSelections(int selectionCount, final Selector selector,
|
||||
@Nullable ServerSocketChannel server,
|
||||
Map<SocketChannel, TcpNioConnection> connections) throws IOException {
|
||||
|
||||
final long now = System.currentTimeMillis();
|
||||
rescheduleDelayedReads(selector, now);
|
||||
if (this.soTimeout > 0 ||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2016 the original author or authors.
|
||||
* Copyright 2001-2018 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.
|
||||
@@ -25,6 +25,7 @@ import java.util.Date;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
import org.springframework.integration.context.OrderlyShutdownCapable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.SchedulingAwareRunnable;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -66,6 +67,7 @@ public abstract class AbstractServerConnectionFactory extends AbstractConnection
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SocketAddress getServerSocketAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2016 the original author or authors.
|
||||
* Copyright 2001-2018 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.
|
||||
@@ -23,6 +23,7 @@ import javax.net.ssl.SSLSession;
|
||||
|
||||
import org.springframework.core.serializer.Deserializer;
|
||||
import org.springframework.core.serializer.Serializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
@@ -116,6 +117,7 @@ public interface TcpConnection extends Runnable {
|
||||
* associated with the connection, but the object should be treated as opaque
|
||||
* and ONLY used as a key.
|
||||
*/
|
||||
@Nullable
|
||||
Object getDeserializerStateKey();
|
||||
|
||||
/**
|
||||
@@ -123,6 +125,7 @@ public interface TcpConnection extends Runnable {
|
||||
* null otherwise.
|
||||
* @since 4.2
|
||||
*/
|
||||
@Nullable
|
||||
SSLSession getSslSession();
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.core.serializer.Deserializer;
|
||||
import org.springframework.core.serializer.Serializer;
|
||||
import org.springframework.integration.ip.IpHeaders;
|
||||
import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.support.ErrorMessage;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -93,7 +94,7 @@ public abstract class TcpConnectionSupport implements TcpConnection {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public TcpConnectionSupport(ApplicationEventPublisher applicationEventPublisher) {
|
||||
public TcpConnectionSupport(@Nullable ApplicationEventPublisher applicationEventPublisher) {
|
||||
this.server = false;
|
||||
this.applicationEventPublisher = applicationEventPublisher;
|
||||
this.socketInfo = null;
|
||||
|
||||
@@ -238,6 +238,7 @@ public class TcpMessageMapper implements
|
||||
* @param connection the connection.
|
||||
* @return A Map of {@code <String, ?>} headers to be added to the message.
|
||||
*/
|
||||
@Nullable
|
||||
protected Map<String, ?> supplyCustomHeaders(TcpConnection connection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2017 the original author or authors.
|
||||
* Copyright 2001-2018 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.
|
||||
@@ -31,6 +31,7 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.core.serializer.Deserializer;
|
||||
import org.springframework.core.serializer.Serializer;
|
||||
import org.springframework.integration.ip.tcp.serializer.SoftEndOfStreamException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.scheduling.SchedulingAwareRunnable;
|
||||
@@ -129,6 +130,7 @@ public class TcpNetConnection extends TcpConnectionSupport implements Scheduling
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getDeserializerStateKey() {
|
||||
try {
|
||||
return inputStream();
|
||||
@@ -139,6 +141,7 @@ public class TcpNetConnection extends TcpConnectionSupport implements Scheduling
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SSLSession getSslSession() {
|
||||
if (this.socket instanceof SSLSocket) {
|
||||
return ((SSLSocket) this.socket).getSession();
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.net.SocketTimeoutException;
|
||||
|
||||
import javax.net.ServerSocketFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -70,6 +71,7 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SocketAddress getServerSocketAddress() {
|
||||
if (this.serverSocket != null) {
|
||||
return this.serverSocket.getLocalSocketAddress();
|
||||
|
||||
@@ -180,7 +180,7 @@ public class TcpNioClientConnectionFactory extends
|
||||
}
|
||||
}
|
||||
}
|
||||
this.processNioSelections(selectionCount, this.selector, null, this.channelMap);
|
||||
processNioSelections(selectionCount, this.selector, null, this.channelMap);
|
||||
}
|
||||
}
|
||||
catch (ClosedSelectorException cse) {
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.core.serializer.Serializer;
|
||||
import org.springframework.integration.ip.tcp.serializer.SoftEndOfStreamException;
|
||||
import org.springframework.integration.util.CompositeExecutor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -183,6 +184,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SSLSession getSslSession() {
|
||||
return null;
|
||||
}
|
||||
@@ -332,6 +334,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
* @return The Message or null if no data is available.
|
||||
* @throws IOException
|
||||
*/
|
||||
@Nullable
|
||||
private synchronized Message<?> convert() throws Exception {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace(getConnectionId() + " checking data avail (convert): " + this.channelInputStream.available() +
|
||||
@@ -711,6 +714,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
return bite;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private byte[] getNextBuffer() throws IOException {
|
||||
byte[] buffer = null;
|
||||
while (buffer == null) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.nio.channels.SocketChannel;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -85,6 +86,7 @@ public class TcpNioServerConnectionFactory extends AbstractServerConnectionFacto
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public SocketAddress getServerSocketAddress() {
|
||||
if (this.serverChannel != null) {
|
||||
try {
|
||||
@@ -235,6 +237,7 @@ public class TcpNioServerConnectionFactory extends AbstractServerConnectionFacto
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TcpNioConnection createTcpNioConnection(SocketChannel socketChannel) {
|
||||
try {
|
||||
TcpNioConnection connection = this.tcpNioConnectionSupport.createNewConnection(socketChannel, true,
|
||||
|
||||
@@ -204,6 +204,7 @@ public class DatagramPacketMessageMapper implements InboundMessageMapper<Datagra
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Message<byte[]> toMessage(DatagramPacket packet, @Nullable Map<String, Object> headers) throws Exception {
|
||||
int offset = packet.getOffset();
|
||||
int length = packet.getLength();
|
||||
|
||||
Reference in New Issue
Block a user