Browse Source

Revert transitive MediaType comparators

The fix made for gh-27488 resulted in a change of the default order
of codecs. This commit reverts these changes, so that the previous
order is restored.

Closes gh-27573
pull/27630/head
Arjen Poutsma 3 years ago
parent
commit
a248a52575
  1. 6
      spring-core/src/main/java/org/springframework/util/MimeType.java
  2. 6
      spring-web/src/main/java/org/springframework/http/MediaType.java

6
spring-core/src/main/java/org/springframework/util/MimeType.java

@ -637,6 +637,9 @@ public class MimeType implements Comparable<MimeType>, Serializable { @@ -637,6 +637,9 @@ public class MimeType implements Comparable<MimeType>, Serializable {
else if (mimeType2.isWildcardType() && !mimeType1.isWildcardType()) { // audio/* > */*
return -1;
}
else if (!mimeType1.getType().equals(mimeType2.getType())) { // audio/basic == text/html
return 0;
}
else { // mediaType1.getType().equals(mediaType2.getType())
if (mimeType1.isWildcardSubtype() && !mimeType2.isWildcardSubtype()) { // audio/* < audio/basic
return 1;
@ -644,6 +647,9 @@ public class MimeType implements Comparable<MimeType>, Serializable { @@ -644,6 +647,9 @@ public class MimeType implements Comparable<MimeType>, Serializable {
else if (mimeType2.isWildcardSubtype() && !mimeType1.isWildcardSubtype()) { // audio/basic > audio/*
return -1;
}
else if (!mimeType1.getSubtype().equals(mimeType2.getSubtype())) { // audio/basic == audio/wave
return 0;
}
else { // mediaType2.getSubtype().equals(mediaType2.getSubtype())
return compareParameters(mimeType1, mimeType2);
}

6
spring-web/src/main/java/org/springframework/http/MediaType.java

@ -798,6 +798,9 @@ public class MediaType extends MimeType implements Serializable { @@ -798,6 +798,9 @@ public class MediaType extends MimeType implements Serializable {
else if (mediaType2.isWildcardType() && !mediaType1.isWildcardType()) { // audio/* > */*
return -1;
}
else if (!mediaType1.getType().equals(mediaType2.getType())) { // audio/basic == text/html
return 0;
}
else { // mediaType1.getType().equals(mediaType2.getType())
if (mediaType1.isWildcardSubtype() && !mediaType2.isWildcardSubtype()) { // audio/* < audio/basic
return 1;
@ -805,6 +808,9 @@ public class MediaType extends MimeType implements Serializable { @@ -805,6 +808,9 @@ public class MediaType extends MimeType implements Serializable {
else if (mediaType2.isWildcardSubtype() && !mediaType1.isWildcardSubtype()) { // audio/basic > audio/*
return -1;
}
else if (!mediaType1.getSubtype().equals(mediaType2.getSubtype())) { // audio/basic == audio/wave
return 0;
}
else {
int paramsSize1 = mediaType1.getParameters().size();
int paramsSize2 = mediaType2.getParameters().size();

Loading…
Cancel
Save