Skip to content

Commit 00bc54d

Browse files
committed
Restore method signatures on MediaType
Previously the method signatures for includes and isCompatibleWith were incompatible with Spring 3.2.x since the argument was now MimeType. This caused NoSuchMethodError to be thrown when a class was compiled against MediaType from Spring 3.2.x and ran against MediaType from Spring 4.x. This commit restores the signatures and implements each method by invoking the super class method. Issue: SPR-10860
1 parent ebcee26 commit 00bc54d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,28 @@ public double getQualityValue() {
295295
return (qualityFactory != null ? Double.parseDouble(unquote(qualityFactory)) : 1D);
296296
}
297297

298+
/**
299+
* Indicate whether this {@code MediaType} includes the given media type.
300+
* <p>For instance, {@code text/*} includes {@code text/plain} and {@code text/html}, and {@code application/*+xml}
301+
* includes {@code application/soap+xml}, etc. This method is <b>not</b> symmetric.
302+
* @param other the reference media type with which to compare
303+
* @return {@code true} if this media type includes the given media type; {@code false} otherwise
304+
*/
305+
public boolean includes(MediaType other) {
306+
return super.includes(other);
307+
}
308+
309+
/**
310+
* Indicate whether this {@code MediaType} is compatible with the given media type.
311+
* <p>For instance, {@code text/*} is compatible with {@code text/plain}, {@code text/html}, and vice versa.
312+
* In effect, this method is similar to {@link #includes(MediaType)}, except that it <b>is</b> symmetric.
313+
* @param other the reference media type with which to compare
314+
* @return {@code true} if this media type is compatible with the given media type; {@code false} otherwise
315+
*/
316+
public boolean isCompatibleWith(MediaType other) {
317+
return super.isCompatibleWith(other);
318+
}
319+
298320
/**
299321
* Return a replica of this instance with the quality value of the given MediaType.
300322
* @return the same instance if the given MediaType doesn't have a quality value, or a new one otherwise

0 commit comments

Comments
 (0)