Buggy code:
public class MockHttpServletRequest implements HttpServletRequest { public static final String DEFAULT_PROTOCOL = "http" ; public static final String DEFAULT_SERVER_ADDR = "127.0.0.1" ; public static final String DEFAULT_SERVER_NAME = "localhost" ; public static final int DEFAULT_SERVER_PORT = 80 ; public static final String DEFAULT_REMOTE_ADDR = "127.0.0.1" ; public static final String DEFAULT_REMOTE_HOST = "localhost" ; private static final String CONTENT_TYPE_HEADER = "Content-Type" ; private static final String CHARSET_PREFIX = "charset=" ; private boolean active = true ; private final Map < String , Object > attributes = new LinkedHashMap < String , Object > ( ) ; private String characterEncoding ; private byte [ ] content ; private String contentType ; private final Map < String , String [ ] > parameters = new LinkedHashMap < String , String [ ] > ( 16 ) ; private String protocol = MockHttpServletRequest . DEFAULT_PROTOCOL ; private String scheme = MockHttpServletRequest . DEFAULT_PROTOCOL ; private String serverName = MockHttpServletRequest . DEFAULT_SERVER_NAME ; private int serverPort = MockHttpServletRequest . DEFAULT_SERVER_PORT ; private String remoteAddr = MockHttpServletRequest . DEFAULT_REMOTE_ADDR ; private String remoteHost = MockHttpServletRequest . DEFAULT_REMOTE_HOST ; private final List < Locale > locales = new LinkedList < Locale > ( ) ; private boolean secure = false ; private final ServletContext servletContext ; private int remotePort = MockHttpServletRequest . DEFAULT_SERVER_PORT ; private String localName = MockHttpServletRequest . DEFAULT_SERVER_NAME ; private String localAddr = MockHttpServletRequest . DEFAULT_SERVER_ADDR ; private int localPort = MockHttpServletRequest . DEFAULT_SERVER_PORT ; private String authType ; private Cookie [ ] cookies ; private final Map < String , HeaderValueHolder > headers = new org . springframework . util . LinkedCaseInsensitiveMap < HeaderValueHolder > ( ) ; private String method ; private String pathInfo ; private String contextPath = "" ; private String queryString ; private String remoteUser ; private final Set < String > userRoles = new HashSet < String > ( ) ; private Principal userPrincipal ; private String requestedSessionId ; private String requestURI ; private String servletPath = "" ; private HttpSession session ; private boolean requestedSessionIdValid = true ; private boolean requestedSessionIdFromCookie = true ; private boolean requestedSessionIdFromURL = false ; public MockHttpServletRequest ( ) { } public MockHttpServletRequest ( String method , String requestURI ) { } public MockHttpServletRequest ( ServletContext servletContext ) { } public MockHttpServletRequest ( ServletContext servletContext , String method , String requestURI ) { } public ServletContext getServletContext ( ) { } public boolean isActive ( ) { } public void close ( ) { } public void invalidate ( ) { } protected void checkActive ( ) throws IllegalStateException { } public Object getAttribute ( String name ) { } public Enumeration < String > getAttributeNames ( ) { } public String getCharacterEncoding ( ) { } public void setCharacterEncoding ( String characterEncoding ) { } private void updateContentTypeHeader ( ) { if ( ( this . contentType ) != null ) { StringBuilder sb = new StringBuilder ( this . contentType ) ; <START_BUG> if ( ( ( this . contentType . toLowerCase ( ) . indexOf ( MockHttpServletRequest . CHARSET_PREFIX ) ) == ( - 1 ) ) && ( ( this . characterEncoding ) != null ) ) { <END_BUG> sb . append ( ";" ) . append ( MockHttpServletRequest . CHARSET_PREFIX ) . append ( this . characterEncoding ) ; } doAddHeaderValue ( MockHttpServletRequest . CONTENT_TYPE_HEADER , sb . toString ( ) , true ) ; } } public void setContent ( byte [ ] content ) { } public int getContentLength ( ) { } public void setContentType ( String contentType ) { } public String getContentType ( ) { } public ServletInputStream getInputStream ( ) { } public void setParameter ( String name , String value ) { } public void setParameter ( String name , String [ ] values ) { } @ SuppressWarnings ( "rawtypes" ) public void setParameters ( Map params ) { } public void addParameter ( String name , String value ) { } public void addParameter ( String name , String [ ] values ) { } @ SuppressWarnings ( "rawtypes" ) public void addParameters ( Map params ) { } public void removeParameter ( String name ) { } public void removeAllParameters ( ) { } public String getParameter ( String name ) { } public Enumeration < String > getParameterNames ( ) { } public String [ ] getParameterValues ( String name ) { } public Map < String , String [ ] > getParameterMap ( ) { } public void setProtocol ( String protocol ) { } public String getProtocol ( ) { } public void setScheme ( String scheme ) { } public String getScheme ( ) { } public void setServerName ( String serverName ) { } public String getServerName ( ) { } public void setServerPort ( int serverPort ) { } public int getServerPort ( ) { } public BufferedReader getReader ( ) throws UnsupportedEncodingException { } public void setRemoteAddr ( String remoteAddr ) { } public String getRemoteAddr ( ) { } public void setRemoteHost ( String remoteHost ) { } public String getRemoteHost ( ) { } public void setAttribute ( String name , Object value ) { } public void removeAttribute ( String name ) { } public void clearAttributes ( ) { } public void addPreferredLocale ( Locale locale ) { } public Locale getLocale ( ) { } public Enumeration < Locale > getLocales ( ) { } public void setSecure ( boolean secure ) { } public boolean isSecure ( ) { } public RequestDispatcher getRequestDispatcher ( String path ) { } public String getRealPath ( String path ) { } public void setRemotePort ( int remotePort ) { } public int getRemotePort ( ) { } public void setLocalName ( String localName ) { } public String getLocalName ( ) { } public void setLocalAddr ( String localAddr ) { } public String getLocalAddr ( ) { }

Fix:
if ( ( ! ( this . contentType . toLowerCase ( ) . contains ( MockHttpServletRequest . CHARSET_PREFIX ) ) ) && ( ( this . characterEncoding ) != null ) ) {