Fix flaky JavaConfigurationTest on Windows by adding retry mechanism for linked resource creation #2068
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Problem
The test
org.eclipse.m2e.jdt.tests.JavaConfigurationTest.testAddSourceResourcewas failing intermittently on Windows with:This race condition occurs when creating linked resources for source folders outside the project directory (e.g.,
../parent/src/main/java). On Windows, the parent project resource may not be fully accessible immediately after project initialization, causing thecreateLink()operation to fail.Solution
Added a retry mechanism with exponential backoff to handle this transient failure:
Implementation Details
New
createLinkWithRetry()method: Wraps thefolder.createLink()call with retry logicHelper method
sleepWithExponentialBackoff(): Provides consistent delay calculationInterruptedExceptionhandling with interrupt flag restorationComprehensive logging:
Example Scenario
Before the fix, on Windows:
After the fix:
Impact
getFolder()This fix should eliminate the flaky test behavior on Windows while maintaining proper error handling for genuine resource access issues.
Testing
The fix has been designed to handle the specific timing issue without requiring changes to the test itself. The retry mechanism will activate only when needed, making the test more resilient to Windows-specific resource initialization timing.
Closes #xxx (replace with actual issue number)
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cbi.eclipse.orgcurl -o org/fusesource/jansi/internal/native/Mac/arm64/libjansi.jnilib -F file=@org/fusesource/jansi/internal/native/Mac/arm64/libjansi.jnilib-tosign REDACTED(dns block)curl -o org/fusesource/jansi/internal/native/Mac/x86/libjansi.jnilib -F file=@org/fusesource/jansi/internal/native/Mac/x86/libjansi.jnilib-tosign REDACTED(dns block)curl -o org/fusesource/jansi/internal/native/Mac/x86_64/libjansi.jnilib -F file=@org/fusesource/jansi/internal/native/Mac/x86_64/libjansi.jnilib-tosign REDACTED(dns block)repo.eclipse.org/usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/m2e-core/m2e-core org.codehaus.plexus.classworlds.launcher.Launcher clean compile -B(dns block)/usr/lib/jvm/temurin-21-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/m2e-core/m2e-core org.codehaus.plexus.classworlds.launcher.Launcher clean install -DskipTests -B -pl org.eclipse.m2e.jdt -am(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>org.eclipse.m2e.jdt.tests.JavaConfigurationTest is flapping on windows</issue_title>
<issue_description>Once in a while the test fails with