Skip to content

Commit 12bc24d

Browse files
committed
File, FTP, IP Sonar Fixes
1 parent 674d5ad commit 12bc24d

File tree

15 files changed

+36
-10
lines changed

15 files changed

+36
-10
lines changed

spring-integration-core/src/main/java/org/springframework/integration/mapping/InboundMessageMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,6 +49,7 @@ default Message<?> toMessage(T object) throws Exception {
4949
* @throws Exception the exception thrown by the underlying mapper implementation
5050
* @since 5.0
5151
*/
52+
@Nullable
5253
Message<?> toMessage(T object, @Nullable Map<String, Object> headers) throws Exception;
5354

5455
}

spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ protected void doInit() {
449449

450450
if (this.destinationDirectoryExpression instanceof LiteralExpression) {
451451
final File directory =
452-
new File(this.destinationDirectoryExpression.getValue(this.evaluationContext, null, String.class));
452+
new File(this.destinationDirectoryExpression.getValue(this.evaluationContext, String.class));
453453

454454
validateDestinationDirectory(directory, this.autoCreateDirectory);
455455
}

spring-integration-ftp/src/main/java/org/springframework/integration/ftp/inbound/FtpInboundFileSynchronizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class FtpInboundFileSynchronizer extends AbstractInboundFileSynchronizer<
4242
*/
4343
public FtpInboundFileSynchronizer(SessionFactory<FTPFile> sessionFactory) {
4444
super(sessionFactory);
45-
doSetRemoteDirectoryExpression(new LiteralExpression(null));
45+
doSetRemoteDirectoryExpression(new LiteralExpression(null)); // NOSONAR - LE can actually handle null ok
4646
doSetFilter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "ftpMessageSource"));
4747
}
4848

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import java.util.concurrent.locks.ReentrantReadWriteLock;
2222

2323
import org.springframework.context.ApplicationEventPublisher;
24+
import org.springframework.lang.Nullable;
2425

2526
/**
2627
* Abstract class for client connection factories; client connection factories
@@ -79,6 +80,7 @@ protected TcpConnectionSupport obtainConnection() throws Exception {
7980
return obtainNewConnection();
8081
}
8182

83+
@Nullable
8284
protected final TcpConnectionSupport obtainSharedConnection() throws InterruptedException {
8385
this.theConnectionLock.readLock().lockInterruptibly();
8486
try {

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractConnectionFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import org.springframework.core.serializer.Serializer;
4949
import org.springframework.integration.context.IntegrationObjectSupport;
5050
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
51+
import org.springframework.lang.Nullable;
5152
import org.springframework.messaging.MessagingException;
5253
import org.springframework.util.Assert;
5354

@@ -610,8 +611,10 @@ protected TcpConnectionSupport wrapConnection(TcpConnectionSupport connection) t
610611
* @param connections Map of connections.
611612
* @throws IOException Any IOException.
612613
*/
613-
protected void processNioSelections(int selectionCount, final Selector selector, ServerSocketChannel server,
614+
protected void processNioSelections(int selectionCount, final Selector selector,
615+
@Nullable ServerSocketChannel server,
614616
Map<SocketChannel, TcpNioConnection> connections) throws IOException {
617+
615618
final long now = System.currentTimeMillis();
616619
rescheduleDelayedReads(selector, now);
617620
if (this.soTimeout > 0 ||

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractServerConnectionFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2001-2016 the original author or authors.
2+
* Copyright 2001-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import org.springframework.context.ApplicationEventPublisher;
2626
import org.springframework.core.task.TaskRejectedException;
2727
import org.springframework.integration.context.OrderlyShutdownCapable;
28+
import org.springframework.lang.Nullable;
2829
import org.springframework.scheduling.SchedulingAwareRunnable;
2930
import org.springframework.scheduling.TaskScheduler;
3031
import org.springframework.util.Assert;
@@ -66,6 +67,7 @@ public boolean isLongLived() {
6667
}
6768

6869
@Override
70+
@Nullable
6971
public SocketAddress getServerSocketAddress() {
7072
return null;
7173
}

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnection.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2001-2016 the original author or authors.
2+
* Copyright 2001-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323

2424
import org.springframework.core.serializer.Deserializer;
2525
import org.springframework.core.serializer.Serializer;
26+
import org.springframework.lang.Nullable;
2627
import org.springframework.messaging.Message;
2728

2829
/**
@@ -116,13 +117,15 @@ public interface TcpConnection extends Runnable {
116117
* associated with the connection, but the object should be treated as opaque
117118
* and ONLY used as a key.
118119
*/
120+
@Nullable
119121
Object getDeserializerStateKey();
120122

121123
/**
122124
* @return the {@link SSLSession} associated with this connection, if SSL is in use,
123125
* null otherwise.
124126
* @since 4.2
125127
*/
128+
@Nullable
126129
SSLSession getSslSession();
127130

128131
/**

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.springframework.core.serializer.Serializer;
3535
import org.springframework.integration.ip.IpHeaders;
3636
import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer;
37+
import org.springframework.lang.Nullable;
3738
import org.springframework.messaging.MessagingException;
3839
import org.springframework.messaging.support.ErrorMessage;
3940
import org.springframework.util.Assert;
@@ -93,7 +94,7 @@ public TcpConnectionSupport() {
9394
this(null);
9495
}
9596

96-
public TcpConnectionSupport(ApplicationEventPublisher applicationEventPublisher) {
97+
public TcpConnectionSupport(@Nullable ApplicationEventPublisher applicationEventPublisher) {
9798
this.server = false;
9899
this.applicationEventPublisher = applicationEventPublisher;
99100
this.socketInfo = null;

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpMessageMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ protected final void addCustomHeaders(TcpConnection connection, MessageHeaders m
238238
* @param connection the connection.
239239
* @return A Map of {@code <String, ?>} headers to be added to the message.
240240
*/
241+
@Nullable
241242
protected Map<String, ?> supplyCustomHeaders(TcpConnection connection) {
242243
return null;
243244
}

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetConnection.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2001-2017 the original author or authors.
2+
* Copyright 2001-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import org.springframework.core.serializer.Deserializer;
3232
import org.springframework.core.serializer.Serializer;
3333
import org.springframework.integration.ip.tcp.serializer.SoftEndOfStreamException;
34+
import org.springframework.lang.Nullable;
3435
import org.springframework.messaging.Message;
3536
import org.springframework.messaging.MessagingException;
3637
import org.springframework.scheduling.SchedulingAwareRunnable;
@@ -129,6 +130,7 @@ public int getPort() {
129130
}
130131

131132
@Override
133+
@Nullable
132134
public Object getDeserializerStateKey() {
133135
try {
134136
return inputStream();
@@ -139,6 +141,7 @@ public Object getDeserializerStateKey() {
139141
}
140142

141143
@Override
144+
@Nullable
142145
public SSLSession getSslSession() {
143146
if (this.socket instanceof SSLSocket) {
144147
return ((SSLSocket) this.socket).getSession();

0 commit comments

Comments
 (0)