Custom Session dirty logic
Fixes spring-projects/spring-integration#2687 Allows any session to implement its dirty logic. * License year was not updated **Cherry-pick to 5.0.x** # Conflicts: # spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/Session.java
This commit is contained in:
committed by
Artem Bilan
parent
23fb52cd20
commit
f63abc161a
@@ -56,6 +56,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author David Turanski
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Alen Turkovic
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
@@ -443,9 +444,7 @@ public class RemoteFileTemplate<F> implements RemoteFileOperations<F>, Initializ
|
||||
return callback.doInSession(session);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (session instanceof CachingSessionFactory<?>.CachedSession) {
|
||||
((CachingSessionFactory.CachedSession) session).dirty();
|
||||
}
|
||||
session.dirty();
|
||||
if (e instanceof MessagingException) {
|
||||
throw (MessagingException) e;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Alen Turkovic
|
||||
* @since 2.0
|
||||
*/
|
||||
public class CachingSessionFactory<F> implements SessionFactory<F>, DisposableBean {
|
||||
@@ -273,6 +274,7 @@ public class CachingSessionFactory<F> implements SessionFactory<F>, DisposableBe
|
||||
return this.targetSession.finalizeRaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dirty() {
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -29,6 +29,7 @@ import java.io.OutputStream;
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Alen Turkovic
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface Session<F> extends Closeable {
|
||||
@@ -107,4 +108,14 @@ public interface Session<F> extends Closeable {
|
||||
*/
|
||||
Object getClientInstance();
|
||||
|
||||
/**
|
||||
* Mark this session as dirty, indicating that it should not be reused and any
|
||||
* delegated sessions should be taken care of before closing.
|
||||
* @see CachingSessionFactory.CachedSession#close()
|
||||
* @since 5.1.2
|
||||
*/
|
||||
default void dirty() {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user