Commit a407ebc
committed
GH-11277: Fix local directory creation race in remote file GET
Fixes: #11277
`generateLocalDirectory()` used a non-atomic `exists()`/`mkdirs()` sequence.
With a `local-directory-expression` the eager `setupLocalDirectory()` in
`afterPropertiesSet()` is skipped, since it only runs for a `ValueExpression`,
so the directory is created per message on the calling thread. Concurrent
messages resolving to the same, not-yet-existing local directory raced on
`File.mkdirs()`: the losing threads received `false` and failed with
`IllegalArgumentException: Failed to make local directory: [...]` although the
directory existed at that point.
* Treat `false` from `mkdirs()` as a failure only when the directory is still
absent - the concurrency-tolerant idiom already used by
`PropertiesPersistingMetadataStore`
`Files.createDirectories()`, as used by `FileWritingMessageHandler` since
GH-11254, is race-tolerant as well, but it makes an `IOException` the root cause
of the reported `IllegalArgumentException`. `FtpServerOutboundTests` and
`SftpServerOutboundTests` assert that root cause, so the thrown exception is
kept unchanged in type, message and cause instead.
Signed-off-by: Jiwoo Lee <dlwldn30@naver.com>1 parent fe5e7d8 commit a407ebc
2 files changed
Lines changed: 72 additions & 1 deletion
File tree
- spring-integration-file/src
- main/java/org/springframework/integration/file/remote/gateway
- test/java/org/springframework/integration/file/remote/gateway
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
1428 | 1429 | | |
1429 | 1430 | | |
1430 | 1431 | | |
1431 | | - | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
1432 | 1435 | | |
1433 | 1436 | | |
1434 | 1437 | | |
| |||
Lines changed: 68 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
809 | 816 | | |
810 | 817 | | |
811 | 818 | | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
812 | 880 | | |
813 | 881 | | |
814 | 882 | | |
| |||
0 commit comments