Commit 078171b
Add comprehensive unit tests and configuration for timestamp preservation
Addresses feedback from PR #388 review comments and adds comprehensive
testing and configuration capabilities for timestamp preservation.
Changes:
1. Fix glob filtering for directory entries (PR #388 feedback)
- Track directories containing matching files during visitFile()
- Only add directory entries in postVisitDirectory() if they contain
matching files or no glob filter is active
- Preserves glob pattern contract while maintaining timestamp preservation
2. Fix Files.exists() race condition (PR #388 feedback)
- Remove unnecessary Files.exists() checks before Files.createDirectories()
- Leverage idempotent behavior of createDirectories()
- Eliminates time-of-check-to-time-of-use (TOCTOU) vulnerability
3. Add error handling for timestamp operations (PR #388 feedback)
- Wrap Files.setLastModifiedTime() in try-catch blocks
- Best-effort timestamp setting with graceful degradation
- Prevents failures on filesystems without timestamp support
4. Add configuration property to control timestamp preservation
- New preserveTimestamps field in AttachedOutputs configuration
- Default value: true (timestamp preservation enabled by default)
- Allows users to disable for performance if needed
- Usage: <attachedOutputs><preserveTimestamps>false</preserveTimestamps></attachedOutputs>
5. Add comprehensive unit tests (CacheUtilsTimestampTest.java)
- testFileTimestampPreservation: Verifies file timestamps preserved
- testDirectoryTimestampPreservation: Verifies directory timestamps preserved
- testDirectoryEntriesStoredInZip: Verifies directories stored in zip
- testTimestampsInZipEntries: Verifies zip entry timestamps correct
- testMavenWarningScenario: Reproduces Maven warning with manual repro steps
- testMultipleFilesTimestampConsistency: Verifies consistent timestamps
- testPreserveTimestampsFalse: Verifies configuration property works when disabled
6. Add test for module-info.class handling (ModuleInfoCachingTest.java)
- Verifies module-info.class is preserved through zip/unzip operations
All tests pass (7 tests in CacheUtilsTimestampTest.java).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent bdb7fe5 commit 078171b
File tree
7 files changed
+618
-21
lines changed- src
- main
- java/org/apache/maven/buildcache
- xml
- mdo
- test/java/org/apache/maven/buildcache
7 files changed
+618
-21
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
881 | 881 | | |
882 | 882 | | |
883 | 883 | | |
884 | | - | |
| 884 | + | |
885 | 885 | | |
886 | 886 | | |
887 | 887 | | |
| |||
896 | 896 | | |
897 | 897 | | |
898 | 898 | | |
899 | | - | |
| 899 | + | |
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
| |||
Lines changed: 80 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
156 | 159 | | |
157 | 160 | | |
158 | 161 | | |
| 162 | + | |
159 | 163 | | |
160 | 164 | | |
161 | 165 | | |
162 | | - | |
| 166 | + | |
| 167 | + | |
163 | 168 | | |
164 | 169 | | |
165 | 170 | | |
166 | 171 | | |
167 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
168 | 180 | | |
169 | 181 | | |
170 | 182 | | |
171 | 183 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
178 | 187 | | |
179 | 188 | | |
180 | 189 | | |
| |||
184 | 193 | | |
185 | 194 | | |
186 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
187 | 205 | | |
188 | 206 | | |
189 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
190 | 210 | | |
191 | 211 | | |
192 | 212 | | |
193 | 213 | | |
194 | 214 | | |
195 | 215 | | |
196 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
197 | 242 | | |
198 | 243 | | |
199 | 244 | | |
200 | 245 | | |
201 | 246 | | |
202 | | - | |
203 | | - | |
| 247 | + | |
| 248 | + | |
204 | 249 | | |
205 | 250 | | |
206 | 251 | | |
| |||
209 | 254 | | |
210 | 255 | | |
211 | 256 | | |
212 | | - | |
213 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
214 | 260 | | |
215 | | - | |
216 | 261 | | |
217 | 262 | | |
218 | | - | |
| 263 | + | |
219 | 264 | | |
220 | 265 | | |
221 | 266 | | |
222 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
223 | 277 | | |
224 | 278 | | |
225 | 279 | | |
226 | 280 | | |
227 | 281 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
232 | 293 | | |
233 | 294 | | |
234 | 295 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
581 | 588 | | |
582 | 589 | | |
583 | 590 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
379 | 385 | | |
380 | 386 | | |
381 | 387 | | |
| |||
0 commit comments