Skip to content

Commit 1d5e66b

Browse files
committed
RemoteFileTemplate: Fix Checkstyle violation
* Add `if (session != null)` in the `RemoteFileTemplate` around `dirty()`
1 parent 6ddcfb3 commit 1d5e66b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

spring-integration-file/src/main/java/org/springframework/integration/file/remote/RemoteFileTemplate.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.springframework.expression.Expression;
3636
import org.springframework.integration.file.DefaultFileNameGenerator;
3737
import org.springframework.integration.file.FileNameGenerator;
38-
import org.springframework.integration.file.remote.session.CachingSessionFactory;
3938
import org.springframework.integration.file.remote.session.Session;
4039
import org.springframework.integration.file.remote.session.SessionFactory;
4140
import org.springframework.integration.file.support.FileExistsMode;
@@ -443,14 +442,16 @@ public <T> T execute(SessionCallback<F, T> callback) {
443442
return callback.doInSession(session);
444443
}
445444
catch (Exception e) {
446-
session.dirty();
445+
if (session != null) {
446+
session.dirty();
447+
}
447448
if (e instanceof MessagingException) {
448449
throw (MessagingException) e;
449450
}
450451
throw new MessagingException("Failed to execute on session", e);
451452
}
452453
finally {
453-
if (!invokeScope) {
454+
if (!invokeScope && session != null) {
454455
try {
455456
session.close();
456457
}

0 commit comments

Comments
 (0)