Skip to content

ReflectionUtils behavior change in 6.2.0 #34082

@welovelain

Description

@welovelain

After upgrading to Spring 6.2.0 (spring boot 3.4.0) my tests with io.rest-assured mock mvc started to be flaky.

I discovered that the issue might be connected to ReflectionUtils.

In RestAssuredMockMvc there is call to
https://github.com/spring-projects/spring-framework/blob/main/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java through ReflectionUtils.

When

public static Method findMethod(Class<?> clazz, String name, @Nullable Class<?>... paramTypes)

is called, then method returns.

Sometimes, method.isVarArgs returns true, sometimes false (when method.isBridge() is true).

Here's some test example to show the behavior:

    @Test
    void testMethod() {
        var method = ReflectionUtils.findMethod(MockHttpServletRequestBuilder.class, "cookie", Cookie[].class);
        System.out.println("IsBridge: " + method.isBridge());
        System.out.println("IsVarArgs: " + method.isVarArgs());

        assertTrue(method.isVarArgs());
    }

If you run the test multiple times, it will fail, but not always. In previous spring version method.isVarArgs always returned true. (At least I think so, it would explain why tests never failed before)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions