Buggy code:
protected static final Log pageNotFoundLogger = LogFactory . getLog ( AnnotationMethodHandlerAdapter . PAGE_NOT_FOUND_LOG_CATEGORY ) ; private UrlPathHelper urlPathHelper = new UrlPathHelper ( ) ; private PathMatcher pathMatcher = new AntPathMatcher ( ) ; private MethodNameResolver methodNameResolver = new InternalPathMethodNameResolver ( ) ; private WebBindingInitializer webBindingInitializer ; private SessionAttributeStore sessionAttributeStore = new DefaultSessionAttributeStore ( ) ; private int cacheSecondsForSessionAttributeHandlers = 0 ; private boolean synchronizeOnSession = false ; private ParameterNameDiscoverer parameterNameDiscoverer = new LocalVariableTableParameterNameDiscoverer ( ) ; private WebArgumentResolver [ ] customArgumentResolvers ; private ModelAndViewResolver [ ] customModelAndViewResolvers ; private HttpMessageConverter < ? > [ ] messageConverters = new HttpMessageConverter [ ] { new ByteArrayHttpMessageConverter ( ) , new StringHttpMessageConverter ( ) , new FormHttpMessageConverter ( ) , new SourceHttpMessageConverter ( ) } ; private ConfigurableBeanFactory beanFactory ; private BeanExpressionContext expressionContext ; private final Map < Class < ? > , AnnotationMethodHandlerAdapter . ServletHandlerMethodResolver > methodResolverCache = new ConcurrentHashMap < Class < ? > , AnnotationMethodHandlerAdapter . ServletHandlerMethodResolver > ( ) ; public AnnotationMethodHandlerAdapter ( ) { } public void setAlwaysUseFullPath ( boolean alwaysUseFullPath ) { } public void setUrlDecode ( boolean urlDecode ) { } public void setUrlPathHelper ( UrlPathHelper urlPathHelper ) { } public void setPathMatcher ( PathMatcher pathMatcher ) { } public void setMethodNameResolver ( MethodNameResolver methodNameResolver ) { } public void setWebBindingInitializer ( WebBindingInitializer webBindingInitializer ) { } public void setSessionAttributeStore ( SessionAttributeStore sessionAttributeStore ) { } public void setCacheSecondsForSessionAttributeHandlers ( int cacheSecondsForSessionAttributeHandlers ) { } public void setSynchronizeOnSession ( boolean synchronizeOnSession ) { } public void setParameterNameDiscoverer ( ParameterNameDiscoverer parameterNameDiscoverer ) { } public void setCustomArgumentResolver ( WebArgumentResolver argumentResolver ) { } public void setCustomArgumentResolvers ( WebArgumentResolver [ ] argumentResolvers ) { } public void setCustomModelAndViewResolver ( ModelAndViewResolver customModelAndViewResolver ) { } public void setCustomModelAndViewResolvers ( ModelAndViewResolver [ ] customModelAndViewResolvers ) { } public void setMessageConverters ( HttpMessageConverter < ? > [ ] messageConverters ) { } public void setBeanFactory ( BeanFactory beanFactory ) { } public boolean supports ( Object handler ) { } public ModelAndView handle ( HttpServletRequest request , HttpServletResponse response , Object handler ) throws Exception { } protected ModelAndView invokeHandlerMethod ( HttpServletRequest request , HttpServletResponse response , Object handler ) throws Exception { } public long getLastModified ( HttpServletRequest request , Object handler ) { } private AnnotationMethodHandlerAdapter . ServletHandlerMethodResolver getMethodResolver ( Object handler ) { } private class ServletHandlerMethodResolver extends HandlerMethodResolver { private ServletHandlerMethodResolver ( Class < ? > handlerType ) { } public Method resolveHandlerMethod ( HttpServletRequest request ) throws ServletException { } private String getMatchedPattern ( String methodLevelPattern , String lookupPath ) { } private boolean isPathMatchInternal ( String pattern , String lookupPath ) { } @ SuppressWarnings ( "unchecked" ) private void extractHandlerMethodUriTemplates ( String mappedPath , String lookupPath , HttpServletRequest request ) { } } private class ServletHandlerMethodInvoker extends HandlerMethodInvoker { private boolean responseArgumentUsed = false ; private ServletHandlerMethodInvoker ( HandlerMethodResolver resolver ) { } @ Override protected void raiseMissingParameterException ( String paramName , Class paramType ) throws Exception { } @ Override protected void raiseSessionRequiredException ( String message ) throws Exception { } @ Override protected Object resolveDefaultValue ( String value ) { } @ Override protected HttpInputMessage createHttpInputMessage ( NativeWebRequest webRequest ) throws Exception { } @ Override protected Object resolveCookieValue ( String cookieName , Class paramType , NativeWebRequest webRequest ) throws Exception { } @ Override @ SuppressWarnings ( { "unchecked" } ) protected String resolvePathVariable ( String pathVarName , Class paramType , NativeWebRequest webRequest ) throws Exception { } @ Override protected Object resolveStandardArgument ( Class parameterType , NativeWebRequest webRequest ) throws Exception { } @ SuppressWarnings ( "unchecked" ) public ModelAndView getModelAndView ( Method handlerMethod , Class handlerType , Object returnValue , ExtendedModelMap implicitModel , ServletWebRequest webRequest ) throws Exception { } @ SuppressWarnings ( "unchecked" ) private void handleResponseBody ( Object returnValue , ServletWebRequest webRequest ) throws IOException , ServletException { HttpInputMessage inputMessage = new org . springframework . http . server . ServletServerHttpRequest ( webRequest . getRequest ( ) ) ; List < MediaType > acceptedMediaTypes = inputMessage . getHeaders ( ) . getAccept ( ) ; HttpOutputMessage outputMessage = new org . springframework . http . server . ServletServerHttpResponse ( webRequest . getResponse ( ) ) ; Class < ? > returnValueType = returnValue . getClass ( ) ; List < MediaType > allSupportedMediaTypes = new ArrayList < MediaType > ( ) ; if ( ( messageConverters ) != null ) { for ( HttpMessageConverter messageConverter : messageConverters ) { allSupportedMediaTypes . addAll ( messageConverter . getSupportedMediaTypes ( ) ) ; if ( messageConverter . supports ( returnValueType ) ) { for ( Object o : messageConverter . getSupportedMediaTypes ( ) ) { MediaType supportedMediaType = ( ( MediaType ) ( o ) ) ; for ( MediaType acceptedMediaType : acceptedMediaTypes ) { <START_BUG> if ( supportedMediaType . includes ( acceptedMediaType ) ) { <END_BUG> messageConverter . write ( returnValue , outputMessage ) ; this . responseArgumentUsed = true ; return ; } } } } } } throw new org . springframework . web . HttpMediaTypeNotAcceptableException ( allSupportedMediaTypes ) ; } } static class RequestMappingInfo { String [ ] paths = new String [ 0 ] ; List < String > matchedPaths = Collections . emptyList ( ) ; RequestMethod [ ] methods = new RequestMethod [ 0 ] ; String [ ] params = new String [ 0 ] ; String [ ] headers = new String [ 0 ] ; public String bestMatchedPath ( ) { } public boolean matches ( HttpServletRequest request ) { } @ Override public boolean equals ( Object obj ) { } @ Override public int hashCode ( ) { } } static class RequestMappingInfoComparator implements Comparator < AnnotationMethodHandlerAdapter . RequestMappingInfo > { private final Comparator < String > pathComparator ; RequestMappingInfoComparator ( Comparator < String > pathComparator ) { } public int compare ( AnnotationMethodHandlerAdapter . RequestMappingInfo info1 , AnnotationMethodHandlerAdapter . RequestMappingInfo info2 ) { } } }

Fix:
if ( acceptedMediaType . includes ( supportedMediaType ) ) {