Commit 2b4a88f
committed
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 that don't support modification times
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).1 parent 84b672e commit 2b4a88f
File tree
7 files changed
+616
-22
lines changed- src
- main
- java/org/apache/maven/buildcache
- xml
- mdo
- test/java/org/apache/maven/buildcache
7 files changed
+616
-22
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: 78 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| 169 | + | |
168 | 170 | | |
169 | 171 | | |
170 | 172 | | |
171 | | - | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| |||
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
182 | 191 | | |
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
| |||
198 | 204 | | |
199 | 205 | | |
200 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
201 | 216 | | |
202 | 217 | | |
203 | 218 | | |
204 | | - | |
205 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
206 | 223 | | |
207 | 224 | | |
208 | 225 | | |
| |||
217 | 234 | | |
218 | 235 | | |
219 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
220 | 262 | | |
221 | 263 | | |
222 | 264 | | |
223 | 265 | | |
224 | 266 | | |
225 | | - | |
| 267 | + | |
226 | 268 | | |
227 | 269 | | |
228 | 270 | | |
229 | 271 | | |
230 | | - | |
| 272 | + | |
231 | 273 | | |
232 | 274 | | |
233 | 275 | | |
| |||
236 | 278 | | |
237 | 279 | | |
238 | 280 | | |
239 | | - | |
240 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
241 | 284 | | |
242 | | - | |
243 | 285 | | |
244 | 286 | | |
245 | | - | |
| 287 | + | |
246 | 288 | | |
247 | 289 | | |
248 | 290 | | |
249 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
250 | 301 | | |
251 | 302 | | |
252 | 303 | | |
| |||
261 | 312 | | |
262 | 313 | | |
263 | 314 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
268 | 326 | | |
269 | 327 | | |
270 | 328 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
588 | 595 | | |
589 | 596 | | |
590 | 597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
385 | 391 | | |
386 | 392 | | |
387 | 393 | | |
| |||
0 commit comments