GH-3271: Close session on error in stream source

Fixes https://github.com/spring-projects/spring-integration/issues/3271

When exception happens at `.withPayload(session.readRaw(remotePath))`
in the `AbstractRemoteFileStreamingMessageSource` we don't close session.
The resource leaking happens in the caching session factory

* Add `session.close();` into the `catch (IOException e) {`
in the `AbstractRemoteFileStreamingMessageSource.doReceive()`
to clean up resources properly

**Cherry-pick to 5.2.x, 5.1.x & 4.3.x**
This commit is contained in:
Artem Bilan
2020-05-11 16:21:30 -04:00
committed by Gary Russell
parent f047f0528b
commit d71fb2e5da
2 changed files with 32 additions and 1 deletions

View File

@@ -216,6 +216,7 @@ public abstract class AbstractRemoteFileStreamingMessageSource<F>
this.fileInfoJson ? file.toJson() : file);
}
catch (IOException e) {
session.close();
throw new UncheckedIOException("IOException when retrieving " + remotePath, e);
}
}