Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResponseEntity's #equals fails symmetric property. [SPR-12910] #17509

spring-issuemaster opened this issue Apr 14, 2015 · 1 comment


None yet
2 participants
Copy link

commented Apr 14, 2015

Austin Davis opened SPR-12910 and commented

The current implementation of ResponseEntity's equals method fails the symmetric property (as defined by Object.equals(Object obj)) as shown in the following test.

public void testSymmetricProperty() {
    HttpHeaders b = new HttpHeaders();
    b.add("headerName", "headerValue");
    String a = "body";
    HttpEntity<String> http = new HttpEntity(a, b);
    ResponseEntity<String> response = new ResponseEntity(a, b, HttpStatus.ACCEPTED);
    assertTrue(http.equals(response)); //Succeeds, http = response
    assertTrue(response.equals(http)); //Fails response != http

This was discovered when attempting to write an equals function for our own subclass of ResponseEntity that had it's own state, testing with equalsVerifier (specific failed assertion, with suggestion on solution here)

Affects: 4.0.6

Referenced from: commits af272c2, 8f6ac19


This comment has been minimized.

Copy link
Collaborator Author

commented Apr 15, 2015

Juergen Hoeller commented

HttpEntity.equals insists on being compared to the same target type now.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.