0

I am working on a Spring boot application. Recently I have updated the dependency in pom.xml as follows:

 <dependency>
     <groupId>net.minidev</groupId>
     <artifactId>json-smart</artifactId>
     <version>2.4.7</version>
 </dependency>

Post this, I am getting Comparison method violates its general contract! exception while doing a rest call as follows:

return restTemplate
        .postForEntity(uri, email, String.class).getBody();

Associated API end point is as follows:

  @GetMapping("/student/{email}")
  public ResponseEntity<Student> getStudent(@PathVariable String email) {
    Optional<Student> student = studentService.findOne(email);
    return ResponseWrapper.wrap(student);
  }
  

I don't understand, how to fix this issue. Could anyone please help here? Thanks.

Joy
  • 4,197
  • 14
  • 61
  • 131
  • I think the issue is not in the code shown above, Can you please add the code of the Student class – Deepak Patankar Jun 12 '21 at 06:55
  • @DeepakPatankar Thanks for your response. Actually, the above code has been working for the past few months. So I was suspecting, it has something to do with this dependency as mentioned in OP. – Joy Jun 12 '21 at 06:59
  • Looking at other answers what I feel is that the comparator of Student might not be transitive https://stackoverflow.com/questions/8327514/comparison-method-violates-its-general-contract. It might be the case that the new dependency is checking for the correct ness of the comparator function and hence we are getting this error. – Deepak Patankar Jun 12 '21 at 07:44

0 Answers0