Skip to content

Commit 565578b

Browse files
committed
RemoteFileTemplate: Fix Checkstyle violation
* Add `if (session != null)` in the `RemoteFileTemplate` around `dirty()` (cherry picked from commit 1d5e66b)
1 parent f63abc1 commit 565578b

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

+4-3
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;
@@ -444,14 +443,16 @@ public <T> T execute(SessionCallback<F, T> callback) {
444443
return callback.doInSession(session);
445444
}
446445
catch (Exception e) {
447-
session.dirty();
446+
if (session != null) {
447+
session.dirty();
448+
}
448449
if (e instanceof MessagingException) {
449450
throw (MessagingException) e;
450451
}
451452
throw new MessagingException("Failed to execute on session", e);
452453
}
453454
finally {
454-
if (!invokeScope) {
455+
if (!invokeScope && session != null) {
455456
try {
456457
session.close();
457458
}

0 commit comments

Comments
 (0)