spring-cloud / spring-cloud-release

Spring Cloud Release Train - dependency management across a wide range of Spring Cloud projects.
http://projects.spring.io/spring-cloud
Apache License 2.0
874 stars 179 forks source link

org.apiguardian.api.API$Status not found after upgrading to 2021.0 and Spring Boot 2.6.1 #231

Closed Zanndorin closed 2 years ago

Zanndorin commented 2 years ago

Describe the bug Getting a lot of

warning: unknown enum constant Status.STABLE
  reason: class file for org.apiguardian.api.API$Status not found 

(and a single)

warning: unknown enum constant Status.EXPERIMENTAL

warnings since upgrading to 2021.0 and Spring Boot 2.6.1, probably cause by SpringMockMVC calls in my junit5 test. Running Java jdk-17+35 from Adoptium and gradle-7.3.1

Sample

@Test
    @DisplayName("Fetch request with empty body should return 400 response")
    public void fetchRestTest400() throws Exception {
        this.mockMvc.perform(post("/metadata")).andDo(print()).andExpect(status().is4xxClientError());
    }
spencergibb commented 2 years ago

What is org.apiguardian.api.API$Status? It doesn't come from spring cloud

Zanndorin commented 2 years ago

It was a "big" issue in 2017, I'm also confused why this should be caused by Spring Cloud but if we change it back to 2020.0.4 and earlier the warning disappears. I haven't really verified, but I assumed it is used via SpringMockMVC so my only guess is that some Spring dependency included in 2021.0.0 now overwrites something and causes this old bug to be back? Haven't found other people having this issue but we were quite early with the update...

(The issue could also be caused by Spring Boot 2.6.X of course or even a Gradle + Spring issue)

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/web/servlet/MockMvc.html

https://github.com/junit-team/junit5/issues/1105

spencergibb commented 2 years ago

Did the change back to 2020.0.4 also include a boot change (since it's not compatible with boot 2.6)? I'm fairly confident that this isn't caused by spring cloud. Can you show your dependencies and the dependency tree from Gradle or maven?

Zanndorin commented 2 years ago

Yes when changing back to Spring Cloud 2020.0.4 we also went to Boot 2.5.X, that was why I wrote 2.6.X and 2021.0.0 vs 2.5.X and 2020.0.4. Have not had time to verify the dependency tree / spend more time on the issue since it felt minor (only warnings and the tests still pass). Just wanted to document it somewhere because I found no one else having the issue and wasn't sure if we were just way to early. We upgraded to 2021.0.0 on Thursday as soon as it was available from Github. I know that they upgraded to JUnit 5.8.1 with Boot 2.6 so maybe I should try and post this to Spring Boot and JUnit too?

spencergibb commented 2 years ago

Not without more information. We currently have no way to verify it reproduce the problem.

Zanndorin commented 2 years ago

Yeah seems like Spring Boot starter Test 2.6.1 updated to Jupiter 5.8.1 which should contain the guardian but doesn't for us for some reason.

https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api/5.8.1

+--- org.springframework.boot:spring-boot-starter-test -> 2.5.4
|    +--- org.junit.jupiter:junit-jupiter:5.7.2
|    |    +--- org.junit:junit-bom:5.7.2
|    |    |    +--- org.junit.jupiter:junit-jupiter:5.7.2 (c)
|    |    |    +--- org.junit.jupiter:junit-jupiter-api:5.7.2 (c)
|    |    |    +--- org.junit.jupiter:junit-jupiter-engine:5.7.2 (c)
|    |    |    +--- org.junit.jupiter:junit-jupiter-params:5.7.2 (c)
|    |    |    +--- org.junit.platform:junit-platform-commons:1.7.2 (c)
|    |    |    \--- org.junit.platform:junit-platform-engine:1.7.2 (c)
|    |    +--- org.junit.jupiter:junit-jupiter-api:5.7.2
|    |    |    +--- org.junit:junit-bom:5.7.2 (*)
|    |    |    +--- org.apiguardian:apiguardian-api:1.1.0
|    |    |    +--- org.opentest4j:opentest4j:1.2.0
|    |    |    \--- org.junit.platform:junit-platform-commons:1.7.2
|    |    |         +--- org.junit:junit-bom:5.7.2 (*)
+--- org.springframework.boot:spring-boot-starter-test -> 2.6.1
|    +--- org.junit.jupiter:junit-jupiter:5.8.1
|    |    +--- org.junit:junit-bom:5.8.1
|    |    |    +--- org.junit.jupiter:junit-jupiter:5.8.1 (c)
|    |    |    +--- org.junit.jupiter:junit-jupiter-api:5.8.1 (c)
|    |    |    +--- org.junit.jupiter:junit-jupiter-engine:5.8.1 (c)
|    |    |    +--- org.junit.jupiter:junit-jupiter-params:5.8.1 (c)
|    |    |    +--- org.junit.platform:junit-platform-commons:1.8.1 (c)
|    |    |    \--- org.junit.platform:junit-platform-engine:1.8.1 (c)
|    |    +--- org.junit.jupiter:junit-jupiter-api:5.8.1
|    |    |    +--- org.junit:junit-bom:5.8.1 (*)
|    |    |    +--- org.opentest4j:opentest4j:1.2.0
|    |    |    \--- org.junit.platform:junit-platform-commons:1.8.1
|    |    |         \--- org.junit:junit-bom:5.8.1 (*)