Skip to content

Fix bytecode ordering dependency in GatewayAutoConfigurationTests#3985

Merged
ryanjbaxter merged 1 commit into
spring-cloud:mainfrom
Kcruz28:fix/nondex-nettyHttpClientConfigured-flakiness
Nov 19, 2025
Merged

Fix bytecode ordering dependency in GatewayAutoConfigurationTests#3985
ryanjbaxter merged 1 commit into
spring-cloud:mainfrom
Kcruz28:fix/nondex-nettyHttpClientConfigured-flakiness

Conversation

@Kcruz28

@Kcruz28 Kcruz28 commented Nov 18, 2025

Copy link
Copy Markdown
Contributor

Problem

Found this while running NonDex on the test suite. When running the test suite with certain bytecode reordering patterns,
GatewayAutoConfigurationTests.nettyHttpClientConfigured fails because Spring Boot
cannot resolve metadata for TestEnableWebfluxSecurityAutoConfiguration.

The issue occurs because:

  1. The test context auto-discovers all autoconfiguration classes in the classpath
  2. Spring Boot's AutoConfigurationSorter tries to read metadata for TestEnableWebfluxSecurityAutoConfiguration
  3. Due to bytecode reordering, the class file becomes temporarily inaccessible during classpath scanning
  4. This results in a FileNotFoundException that breaks the test

Solution

Use Spring Boot's FilteredClassLoader to explicitly exclude TestEnableWebfluxSecurityAutoConfiguration
from the test's classloader. This prevents Spring Boot from trying to discover and load metadata for
the test-only autoconfiguration, while keeping all other functionality intact.

The change is minimal:

  • Adds .withClassLoader(new FilteredClassLoader(...)) to exclude the problematic class
  • No changes to test logic or assertions
  • No changes to production code

Why This Matters

This type of issue indicates a hidden dependency on bytecode ordering within the test setup.
By fixing it, we:

  • Ensure consistent test behavior across different execution environments
  • Prevent intermittent CI/CD failures that are hard to debug
  • Make the test more robust to future changes in classloading order

@Kcruz28 Kcruz28 changed the title Prevent TestEnableWebfluxSecurityAutoConfiguration from interfering with Spring Boot's autoconfiguration metadata resolution Fix bytecode ordering dependency in GatewayAutoConfigurationTests Nov 18, 2025
…uffling

The test was failing intermittently under NonDex shuffling due to Spring Boot's
inability to read metadata for TestEnableWebfluxSecurityAutoConfiguration - a test-only
autoconfiguration class. When NonDex reorders bytecode, Spring Boot's ClassPathResource
loading fails because the class is not properly accessible during metadata resolution.

This fix uses FilteredClassLoader to exclude TestEnableWebfluxSecurityAutoConfiguration
from the test context, preventing the flakiness while maintaining test integrity.

The test was classified as Implementation-Dependent (ID) by NonDex, indicating that
its behavior depends on bytecode ordering rather than logical test flow.

Signed-off-by: kcruz28 <kcruz28@illinois.edu>
@Kcruz28
Kcruz28 force-pushed the fix/nondex-nettyHttpClientConfigured-flakiness branch from 9de347b to 626b6f5 Compare November 18, 2025 11:14
@ryanjbaxter ryanjbaxter added this to the 5.0.0 milestone Nov 19, 2025
@github-project-automation github-project-automation Bot moved this to Todo in 2025.1.0 Nov 19, 2025
@ryanjbaxter
ryanjbaxter merged commit 2445f80 into spring-cloud:main Nov 19, 2025
2 of 3 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in 2025.1.0 Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants