When client request to spring web with header Accept: application/xml, */*, */*, */*, */*, */*
, then spring web will meet excpetion and return HTTP Status 500 – Internal Server Error
.
This is a bug, and exception stack is
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeLo(TimSort.java:777)
at java.util.TimSort.mergeAt(TimSort.java:514)
at java.util.TimSort.mergeCollapse(TimSort.java:441)
at java.util.TimSort.sort(TimSort.java:245)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1462)
at org.springframework.http.MediaType.sortBySpecificityAndQuality(MediaType.java:734)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:259)
version Spring Web 5.2.13.RELEASE
Comment From: rstoyanchev
I cannot reproduce the issue. I've tried with 5.2.13 and also the latest 5.3.4.
Maybe try with different JDK versions and also see if the following reproduces the issue for you more easily:
List<MediaType> mediaTypes = MediaType.parseMediaTypes("application/xml, */*, */*, */*, */*, */*");
MediaType.sortBySpecificityAndQuality(mediaTypes);
Comment From: EdAndrew
openjdk version "1.8.0_71" OpenJDK Runtime Environment (build 1.8.0_71-b15) OpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)
I use this JDK and find the problem, may this infomation can help you.
Comment From: rstoyanchev
You're using and old version. A more recent version is 1.8.0_282. Does the above test reproduce your issue?
If you want us to look further, please provide a reproducible test.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.