-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed as not planned
Closed as not planned
Copy link
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
Affects: 6.0.x - tested with 6.0.4
The signature of ResponseEntity#getStatusCode
was changed in Spring Framework 6.x - it now returns HttpStatusCode
(Spring 5.x returned HttpStatus
) - see #28214. The idea was that the change is backward compatible.
How to reproduce:
-
Create this simple test class in a file
Test.java
:// Test.java import org.springframework.http.ResponseEntity; public class Test { public static void main(String[] args) { ResponseEntity<Object> ok = ResponseEntity.ok().build(); if (ok.getStatusCode().is2xxSuccessful()) { System.out.println("OK"); } } }
-
Compile the application with Spring 5.3.x:
javac -cp $HOME/.m2/repository/org/springframework/spring-web/5.3.24/spring-web-5.3.24.jar Test.java
-
Run the application with Spring 6.0x:
java -cp "$HOME/.m2/repository/org/springframework/spring-web/6.0.4/spring-web-6.0.4.jar:$HOME/.m2/repository/org/springframework/spring-core/6.0.4/spring-core-6.0.4.jar:." Test Exception in thread "main" java.lang.NoSuchMethodError: 'org.springframework.http.HttpStatus org.springframework.http.ResponseEntity.getStatusCode()' at Test.main(Test.java:6)
With Spring 5.3.x it works as expected:
java -cp "$HOME/.m2/repository/org/springframework/spring-web/5.3.24/spring-web-5.3.24.jar:$HOME/.m2/repository/org/springframework/spring-core/5.3.24/spring-core-5.3.24.jar:." Test OK
Metadata
Metadata
Assignees
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid