Commit Graph

501 Commits

Author SHA1 Message Date
Gary Russell
12bc24dd02 File, FTP, IP Sonar Fixes 2018-10-26 13:53:54 -04:00
Artem Bilan
674d5adfc0 INT-4114: Add missed <poller> to XSDs
JIRA: https://jira.spring.io/browse/INT-4114
2018-10-26 13:51:18 -04:00
Gary Russell
a4f779d09e INT-4547: (S)FTP RFOG MPUT with collection payload
JIRA: https://jira.spring.io/browse/INT-4547

* PR Comments; use `MutableMessage` internally.
2018-10-24 15:33:29 -04:00
Gary Russell
bd7a3bc4ed GH-2605: (S)FTP test cached sessions
Resolves https://github.com/spring-projects/spring-integration/issues/2605

* Suppress unused field warning.

* Fix typos.

* Use lstat() - don't follow symbolic lincs
2018-10-23 13:59:00 -04:00
Gary Russell
0a7c77d853 INT-4534: Add remote directory to exception
JIRA: https://jira.spring.io/browse/INT-4534

Include the remote directory in exception and debug log messages when synchronizing.
2018-10-11 08:58:53 -04:00
Artem Bilan
41264110ce Some various polishing
* Add `RotatingServerAdvice.StandardRotationPolicy.getCurrent()` method
for better end-user experience when this class is extended
* Add NPE protection into the MQTT Channel Adapters.
Some code style polishing for them

**Cherry-pick to 5.0.x**
2018-10-10 15:21:58 -04:00
Artem Bilan
9e9fa2cf58 RemoteFTempl: InputStream.close() in the finally
If exception happens in the `callback.doWithInputStream(inputStream)`,
we don't close the `inputStream = session.readRaw(remotePath)`.

* Move the `InputStream.close()` to the `finally` block of the
`SessionCallback` action in the `RemoteFileTemplate.get()`

**Cherry-pick to 5.0.x and 4.3.x**
2018-10-05 12:17:50 -04:00
Steven
4f2372b02a FileReadingMS: Make an Assert message more clear
* Changed an Assert error message in the `FileReadingMessageSource` to make the requirements 
when using an external scanner clearer, and added some explanatory comments.

* Removed use of 'local' to eliminate confusion.

* Added javadoc addendum
2018-09-21 11:36:59 -04:00
Cengis K
b295fb8486 GH-2569: Add ChainFileListFilter constructors
* Adding ChainFileListFilter constructors to behave like CompositeFileListFilter

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

Adding constructors in `ChainFileListFilter` matching super, so this class behave 
like `CompositeFileListFilter` when using XML flow configuration.

* Fix import error

* Fix checkstyle

* Fix checkstyle

* Fix checkstyle

* Fix author name case
Remove unnecessary javadoc

* Fix code smell squid:S1155

* Add a simple test case for initializing filters with constructor
Fix code smell squid:S1192

* Add a simple test case for initializing filters with constructor
Fix code smell squid:S1192

* Fix missing import
2018-09-21 11:32:16 -04:00
Michael Forstner
5bfd6971db INT-4531: Use Object type KeyDirectory.key
JIRA: https://jira.spring.io/browse/INT-4531

The `DelegatingSessionFactory` uses plain `Object` as key type
whereas the default `RotatingServerAdvice` does not.

* Change the type from `String` to `Object` in the `RotatingServerAdvice.KeyDirectory`
* Fix typos in the (s)ftp.adoc

**Cherry-pick to 5.0.x**
2018-09-14 12:49:05 -04:00
Artem Bilan
e4ca8571e0 File Source: do not deal with dir until start()
StackOverflow: https://stackoverflow.com/questions/52273537/spring-boot-failed-to-load-applicationcontext
2018-09-12 10:13:45 -04:00
Gary Russell
5ab7d24934 Make Headers PREFIX Constants Public
**cherry-pick to 5.0.x**

* Make `IpHeaders` prefix as `public` as well
2018-08-27 16:44:49 -04:00
Artem Bilan
e053e2ab4a INT-4524: Fix MailReceivingMessageSource BF usage
JIRA: https://jira.spring.io/browse/INT-4524
2018-08-20 12:17:48 -04:00
Gary Russell
23a3462d8b Add @NonNullApi where appropriate
Packages with `@Nullable` annotations need to have `@NonNulApi` at the package level.

There may be classes in these packages that have nullable arguments/returns that are
not currently marked as `@Nullable`. These will be fixed over time.

Also suppress JSR305 warnings when compiling tests.

* Polishing - PR Comments
2018-08-01 16:53:42 -04:00
Artem Bilan
0d0605be78 INT-4381: MessageSources refactoring (#2517)
* INT-4381: MessageSources refactoring

JIRA: https://jira.spring.io/browse/INT-4381

* Make all the out-of-the-box `MessageSource` implementations based
on the `AbstractMessageSource`
* Fix `JdbcPollingChannelAdapterIntegrationTests` for sporadic failure
because of `fixed-rate` for the poller

* Fix HeaderEnricherTests race condition

The `errorChannel()` expect an error in the `testErrorChannel` after
`1000` ms, but at the same time the `poller` in configured for the
`3000` ms.

* Increase all the timeouts for replies
* Decrease a `fixed-delay` on the `poller`
* Some other code style polishing for the `HeaderEnricherTests`
2018-07-25 13:01:22 -04:00
Gary Russell
d6c8baf50f INT-4505: Fix package tangle
JIRA: https://jira.spring.io/browse/INT-4505
2018-07-24 16:30:10 -04:00
Artem Bilan
44b7df94c1 Polishing for the FileWritingMessageHandler
* Fix typos in docs
* Add `om.google.code.findbugs:jsr305` to avoid warnings like
`Cannot find annotation`
2018-07-24 15:50:56 -04:00
Alen Turkovic
9ac0746f19 INT-4502: Add new file callback in FileWritingMH
JIRA: https://jira.spring.io/browse/INT-4502

Documentation
Using a BiConsumer instead of a custom interface

Doc fixes

Calling callback while locked

More requested fixes

Missing `FileWritingMessageHandler.this` on `fileExistsMode`
2018-07-24 15:50:05 -04:00
Artem Bilan
76877b9440 INT-4499: Add JdbcMetadataStore.setLockHint()
JIRA https://jira.spring.io/browse/INT-4499
Fixes https://github.com/spring-projects/spring-integration/issues/2483

To allow to reconfigure a `SELECT ... FOR UPDATE` for particular RDBMS
vendor, we need an option to specify possible hint for the target data base.

**Cherry-pick to 5.0.x**
2018-07-11 17:52:44 -04:00
Artem Bilan
a1f016a94c INT-4498: StreamUtils -> FileCopyUtils
JIRA: https://jira.spring.io/browse/INT-4498

* Use `FileCopyUtils` instead of `StreamUtils` in test-cases when we deal
with `InputStream` s and files resources.
* Fix reflection-based tests with AOP to use an `ArrayList` access
instead of `LinkedList` since an optimization in SF:
6d6aa72e8f

**Cherry-pick to 5.0.x and 4.3.x**
2018-07-09 13:39:56 -04:00
Gary Russell
11d39b7da1 INT-4496: (S)FTP: Sort file list earlier
JIRA: https://jira.spring.io/browse/INT-4496

Sort the file list before applying `maxFetchSize` and filters.

* Polishing - PR Comments
2018-07-02 16:49:23 -04:00
Gary Russell
3f218a97a0 INT-4495: (S)FTP: fix max-fetch with directories
JIRA: https://jira.spring.io/browse/INT-4495

Previously, `maxFetch` was applied before directories were removed from
the fetch list.

Remove the directories before filtering and applying `maxFetch`.

* Polishing - PR Comments

* More polishing

* More polishing.

* Check for empty array.

* Remove test main method.
2018-06-29 14:21:06 -04:00
Gary Russell
26cfab579c INT-4491: (S)FTP inbound rotate dirs/servers
JIRA: https://jira.spring.io/browse/INT-4491

Add Rotating Server/Directory Polling Advice.

**cherry-pick to 5.0.x**

* Polishing - PR Comments.

* Polishing

* Polishing; revert `KeyDirectory`; WARN about `TaskExecutor` and `MessageSoureMutator`(s).

* More polishing - PR comments

* Apply stashed changes.

* Fix WARN log - the `SyncTaskExecutor` is wrapped.
2018-06-27 13:43:41 -04:00
Artem Bilan
ad4dc11758 GH-2478: RecursiveDScanner: Files.walk().close()
Fixes https://github.com/spring-projects/spring-integration/issues/2478

The `Files.walk()` stream must be closed in the end after usage

* Wrap `Files.walk()` to the `try-with-resources`

**Cherry-pick to 5.0.x**
2018-06-13 12:33:16 -04:00
Artem Bilan
85bc183849 INT-4486: Properly implement stop(Runnable)
JIRA: https://jira.spring.io/browse/INT-4486

The `SmartLifecycle.stop(Runnable callback)` must always call the
`callback` in the end independently of the internal state

* Revise all the `SmartLifecycle` implementations for the proper
`callback` handling

**Cherry-pick to 5.0.x and 4.3.x**
2018-06-11 17:51:20 -04:00
Artem Bilan
1f05d3ec4c Polishing some Docs and JavaDocs
* Mentioned `byte[]` support for the `UnmarshallingTransformer`
* Fix `AbstractInboundFileSynchronizingMessageSource` JavaDocs to
mention the current `FileSystemPersistentAcceptOnceFileListFilter`
usage by default, not an `AcceptOnceFileListFilter`
* Polishing `AbstractInboundFileSynchronizingMessageSource` code style
a bit
2018-05-16 16:10:50 -04:00
Artem Bilan
0ef659b8a7 INT-4351: Add DiscardAwareFileListFilter
JIRA: https://jira.spring.io/browse/INT-4351

The `WatchService` reacts to the events in the file system and keep
track ove the events until we poll them, e.g. via `listEligibleFiles()`
in the `WatchServiceDirectoryScanner`.
On the other hand the `SourcePollingChannelAdapter` calls the mentioned
`listEligibleFiles()` according its polling period.
At this moment the `FileListFilter` is applied to the polled files.
It may happen that `LastModifiedFileListFilter` can't accept too young
files yet and they are lost for the future consideration.

* To allow, for example, to retain young files by the
`LastModifiedFileListFilter` judgment for the future cycles add
`DiscardAwareFileListFilter` with the `DiscardCallback` support.
The `WatchServiceDirectoryScanner` now registers such a callback into
the filter and stores discarded files into the `filesToPoll` queue
for the future poll cycle.

**Cherry-pick to 5.0**

Fix compilation warnings

* Replace `DiscardCallback` with the plain `Consumer`
* Ensure uniqueness in the `WatchServiceDirectoryScanner` internal
queue via a `Set` implementation, since discard callback may be called
several times for the same file from the `CompositeFileListFilter`
according to its nature
* Add JavaDocs and Docs

Change `@since` to `5.0.5`
2018-04-24 14:10:15 -04:00
Artem Bilan
027021d6e4 Move XSDs to version 5.1
* Upgrade to Spring AMQP-2.1 and fix compatibility
2018-03-17 09:58:40 -04:00
Gary Russell
82f252dd00 INT-4390: Fix tangles
JIRA: https://jira.spring.io/browse/INT-4390

Phase I: flow context/registration cycle

- extract interfaces
- rename implementations to `Standard...`

Phase II - dsl<->dsl.channel tangles

Move the channel specs to dsl.

Fix missing refactorings

(Not related to DSL) - rename core `event` package to `events`

- avoid collision with event module package
- fix tangle caused by `MessageGroupExpiredEvent`.

Phase III - dsl<->config.dsl

- move classes from config.dsl to dsl

(Not related to DSL) - fix many tangles caused by graph being a sub-package of support.management
 - make `graph` a top-level package

(Not related to DSL) - move `IntegrationManagementConfigurer` from
`management` to `config` - tangle between core and management
* Polishing Copyrights, diamonds, some JavaDocs and What's New
2018-03-16 14:59:47 -04:00
Ruslan Stelmachenko
7f25cba262 INT-4430: FileSplitter close reader on exception
JIRA: https://jira.spring.io/browse/INT-4430

When Iterator-based `FileSplitter` splits the file, and an exception 
throws in downstream flow (in the same thread), the exception propagates 
to the caller leaving underlying file reader opened.

This commit changes `AbstractMessageSplitter` the way, that, 
when any exception happens, if Iterator implements `java.io.Closeable`, 
its `close()` method will be called before propagating exception.

Also `FileSplitter`'s underlying iterator implements `Closeable` now.

* Make `CloseableIterator` to follow `Closeable` contract.

Now `CloseableIterator.close()` declares `IOException` and can be used 
as base interface for `FunctionIterator`.

* Adjust tests.

Adjust tests to reflect the fact that we call `close()` on the reader 
one more time in the end of iterator.

**Cherry-pick to 5.0.x and 4.3.x**
2018-03-16 10:26:41 -04:00
Gary Russell
4552a80095 INT-4392: Fix tangles
JIRA: https://jira.spring.io/browse/INT-4392
JIRA: https://jira.spring.io/browse/INT-4391
JIRA: https://jira.spring.io/browse/INT-4393

Resolve class and leaf package tangles in:

- core (except DSL)
- file
- http

- move `StaticMessageHeaderAccessor` to root `integration` package
- move acknowledgment related classes to a new `acks` package
- move `MMIH` to `handler.support`, alongside argument resolvers, also `HandlerMethodArgumentResolversHolder`
- move `ErrorMessagePublisher` to `core`
- move `PatternMatchUtils` to `support.utils`
- move `MessageSourceManagement` to `support.management`
- remove direct reference to `MicrometerMetricsCapter` from `IntegrationManagementSupport`
- add new class `MetricsCaptorLoader`

- move `OperationsCallback` to inner interface in `RemoteFileOperations`

- move `HttpContextUtils` to `config`

* Simplify MetricsCaptor loading.

* Polishing
2018-03-13 11:22:56 -04:00
Artem Bilan
3fa777db5e Expose scan-each-poll for File Inbound Ch Adapter
The `scan-each-poll` XML attribute is missing for the
`<int-file:inbound-channel-adapter>`
2018-01-26 13:12:13 -05:00
Gary Russell
55d92edd4e INT-4382: Fix deadlock in FileWritingMH
JIRA: https://jira.spring.io/browse/INT-4382

There is a deadlock in the FMWH due to lock ordering.

Writes try to lock the handler monitor while holding the file lock.
The `Flusher` tries to lock the file lock while holding th handler monitor.

- Change the `Flusher`, `stop` and `flushIfNeeded` methods to not call close
  on the file state while holding the handler monitor.

__cherry pick to 4.3.x__ (fix <> for Java 6)

Polishing - PR Comments

* Optimize `flushIfNeeded(FlushPredicate)` to delegate only to the
`flushIfNeeded(MessageFlushPredicate, Message<?>)`
2018-01-22 11:45:40 -05:00
Artem Bilan
86c76999f6 Optimize AbstractMessageSources
To avoid `Message` re-creation during `AbstractMessageSource.receive()`
logic, refactor `AbstractMessageSource` implementations
to return `AbstractIntegrationMessageBuilder`

* Add `AbstractIntegrationMessageBuilder<File> doReceive()` to the
`FileReadingMessageSource` to be called from the `AbstractInboundFileSynchronizingMessageSource`
to avoid message recreation in its `doReceive()`
* Some code style refactoring in the `AbstractMessageSource`
2018-01-18 11:17:03 -05:00
Artem Bilan
30450c48be INT-4376: Upgage to Log4J 2 (#2321)
* INT-4376: Upgage to Log4J 2

JIRA: https://jira.spring.io/browse/INT-4376

* Deprecate Log4J 1.x components in favor of newly added
a `Log4j2LevelAdjuster` JUnit `@Rule`
* Update all the logging configuration to Log4J 2

* Polishing after testing
2018-01-11 10:59:55 -05:00
Gary Russell
f21f81092d INT-4369: Add DeliveryAttempt header
JIRA: https://jira.spring.io/browse/INT-4369

Also add `StaticMessageHeaderAccessor`

- avoids object creation when getting type-safe well-known headers.

* Docs
2018-01-02 16:17:32 -05:00
Artem Bilan
077b5ffffc INT-4344: AbstRemoteFileOutGw: Add assert for NPE
JIRA: https://jira.spring.io/browse/INT-4344

The `FtpOutboundGateway` provides ctors without expression for remote path.
In this case it is treated as a `working directory` but only for the
`LS`, `NLST`, `PUT` and `MPUT` commands.

* Add assertion in the `AbstractRemoteFileOutboundGateway` to discard
configuration for all other commands when `expression` is `null`

**Cherry-pick to 4.3.x**
2017-10-16 17:04:22 -04:00
Artem Bilan
bf63ef5491 GH-2253: Revert (S)FTP Source to DefaultDirScann
Fixes spring-projects/spring-integration#2253

For backward compatibility and use-cases when processed files are stored
in sub-directories in the `localDirectory` revert the
`AbstractInboundFileSynchronizingMessageSource` logic back to the
`DefaultDirectoryScanner`.
The `RecursiveDirectoryScanner` can be injected via `scanner` option
2017-10-16 16:05:44 -04:00
Artem Bilan
1fa73a9728 INT-4356: FileTransferMH: Add string SpEL setters
JIRA: https://jira.spring.io/browse/INT-4356

**Cherry-pick to 4.3.x**

Address PR comments:
* Remove unused variable in the test case
* Add string-based SpEL setters to the `AbstractInboundFileSynchronizer`
* Fix `@since` in the `FileTransferringMessageHandler` to the proper version
2017-10-16 15:51:12 -04:00
Venil Noronha
797e5045bf INT-4334: Adds a DirectoryScanner to RemoteFileMS
JIRA: https://jira.springsource.org/browse/INT-4334

* Add a `DirectoryScanner` setter named `setScanner` in
`AbstractInboundFileSynchronizingMessageSource` to set the
`FileReadingMessageSource`'s scanner.
* Add tests to `AbstractRemoteFileSynchronizerTests`.

Polish.

Updates xsd, tests and documentation.

Fix xsd formatting.

Addresses review comments.

* Some code style polishing
2017-09-25 21:08:51 -04:00
Artem Bilan
ab9e843cfa Fix Checkstyle violations
* Add `validateOnlyOverlapping = false` for `RequireThis` Checkstyle rule
* Add `this.` to caught places
* Use `CustomizableThreadFactory` instead of raw interface in the
`UnicastSendingMessageHandler`
2017-08-15 13:36:19 -04:00
Artem Bilan
32fdd2119f INT-4324: File Outbound: parse preserve-timestamp
JIRA: https://jira.spring.io/browse/INT-4324

The `preserve-timestamp` attribute for the
`<int-file:outbound-channel-adapter>` has been missed for parsing in
the `FileWritingMessageHandlerBeanDefinitionBuilder` and propagation
in the `FileWritingMessageHandlerFactoryBean`

**Cherry-pick to 4.3.x**
2017-08-08 11:47:32 -04:00
Artem Bilan
f00eafb4f8 GH-152: Scanner & filters are mutually exclusive
Fix spring-projects/spring-integration-java-dsl#152

* Add Logic to the `FileInboundChannelAdapterSpec` do not populate
`FileListFilterFactoryBean` to the `FileReadingMessageSource`
when the `scanner` is provided.
Otherwise call the `FileReadingMessageSource` and rely on its logic to
refuse mutually exclusive `scanner` and `filter/locker` options
2017-07-31 10:52:29 -04:00
Artem Bilan
e475d9c695 INT-4308: Document JdbcMetadataStore
JIRA: https://jira.spring.io/browse/INT-4308

* Document `JdbcMetadataStore`
* Remove unnecessary context DERBY config for the `PersistentAcceptOnceFileListFilterExternalStoreTests`
* Rework the `testFileSystemWithJdbcMetadataStore()` to use `EmbeddedDatabase` directly, without context
2017-07-20 10:55:03 -04:00
Artem Bilan
4663862ea6 Resolve deprecations since the latest SF 2017-07-11 11:52:11 -04:00
Bojan Vukasovic
47003077cc INT-4306: Add support for JdbcMetadataStore
JIRA: https://jira.spring.io/browse/INT-4306

Fixed checkstyle errors

Fixed checkstyle errors

Fixed checkstyle errors and sql schema

Manually fixed derby sql schema

Fixing some issues

added region support

small refactorings

test checkstyle fix

integration tests and fixes

integration tests and fixes
2017-06-29 13:44:28 -04:00
Artem Bilan
72bd4e5bcf INT-4305: (S)FTP: Remove Local File Before Rename
JIRA: https://jira.spring.io/browse/INT-4305

The `File.renameTo()` operation may fail, therefore the content of the
local file isn't changed, but since we change `setLastModified()` anyway,
this file might be eligible for local polling.
So, we end up with the same content from local file in a new message,
meanwhile we expect a new content from the remote file

* Check the `File.renameTo()` result and attempt to `delete()`
for existing local file
* When file isn't renames remove the remote file from the `filter` to let
it be transferred one more time on the next poll.
The local file might be opened for processing, so this way we postpone a fresh
remote file for the future poll rounds
* Modify `copyFileToLocalDirectory()` to return `boolean` to reflect the fact of copy.
This way we check the real number of transferred files

**Cherry-pick to 4.3.x**

Do not transfer remote file if we can't remove local one

Polishing Log Messages
2017-06-27 16:45:15 -04:00
Gary Russell
36ac9f2203 (S)FTP MaxFetchSize Doc Polishing and DSL
Also polish programming tips and tricks docs.

* Fix typos in docs
2017-06-27 15:45:40 -04:00
Artem Bilan
d8382e0bd0 INT-4297: Add FileSplitter.setFirstLineAsHeader()
JIRA: https://jira.spring.io/browse/INT-4297

* Add `FileSplitter.setFirstLineAsHeader()` and extract the first line from
the context before `iterator`.
* Populate the extracted header to each subsequent line

* Don't use `Streams` to read first line
* Add XSD and Java DSL option for the `firstLineAsHeader`
* Document the feature
* Add Java DSL sample for the `Files.slitter()`

Add a note about more complex header enrichment

Doc Polishing and fix field name.
2017-06-27 13:14:10 -04:00
Gary Russell
5216dc2b02 INT-4304 (S)FTP Outbound Gateway Delete After GET
JIRA: https://jira.spring.io/browse/INT-4304

Add an option to delete remote file(s) after GET/MGET.

Polishing - log error on delete failure.
2017-06-26 14:30:08 -04:00