Buggy code:
public abstract class AbstractResource implements IResource { private static final long serialVersionUID = 1L ; public AbstractResource ( ) { } protected abstract AbstractResource . ResourceResponse newResourceResponse ( Attributes attributes ) { } public static class ResourceResponse { private Integer errorCode ; private String errorMessage ; private String fileName = null ; private ContentDisposition contentDisposition = ContentDisposition . INLINE ; private String contentType = null ; private String textEncoding ; private long contentLength = - 1 ; private Date lastModified = null ; private AbstractResource . WriteCallback writeCallback ; private Duration cacheDuration ; private CacheScope cacheScope ; public ResourceResponse ( ) { } public void setError ( Integer errorCode ) { } public void setError ( Integer errorCode , String errorMessage ) { } public Integer getErrorCode ( ) { } public String getErrorMessage ( ) { } public void setFileName ( String fileName ) { } public String getFileName ( ) { } public void setContentDisposition ( ContentDisposition contentDisposition ) { } public ContentDisposition getContentDisposition ( ) { } public void setContentType ( String contentType ) { } public String getContentType ( ) { } public void setTextEncoding ( String textEncoding ) { } protected String getTextEncoding ( ) { } public void setContentLength ( long contentLength ) { } public long getContentLength ( ) { } public void setLastModified ( Date lastModified ) { } public Date getLastModified ( ) { } public boolean dataNeedsToBeWritten ( Attributes attributes ) { } public void disableCaching ( ) { } public void setCacheDurationToMaximum ( ) { } public void setCacheDuration ( Duration duration ) { } public Duration getCacheDuration ( ) { } public CacheScope getCacheScope ( ) { } public void setCacheScope ( WebResponse . CacheScope scope ) { } public void setWriteCallback ( final AbstractResource . WriteCallback writeCallback ) { } public AbstractResource . WriteCallback getWriteCallback ( ) { } } protected void configureCache ( final WebRequest request , final WebResponse response , final AbstractResource . ResourceResponse data , final Attributes attributes ) { } public final void respond ( final Attributes attributes ) { AbstractResource . ResourceResponse data = newResourceResponse ( attributes ) ; WebRequest request = ( ( WebRequest ) ( attributes . getRequest ( ) ) ) ; WebResponse response = ( ( WebResponse ) ( attributes . getResponse ( ) ) ) ; Date lastModified = data . getLastModified ( ) ; if ( lastModified != null ) { response . setLastModifiedTime ( lastModified . getTime ( ) ) ; } configureCache ( request , response , data , attributes ) ; if ( ! ( data . dataNeedsToBeWritten ( attributes ) ) ) { response . setStatus ( SC_NOT_MODIFIED ) ; return ; } if ( ( data . getErrorCode ( ) ) != null ) { response . sendError ( data . getErrorCode ( ) , data . getErrorMessage ( ) ) ; return ; } if ( ( data . getWriteCallback ( ) ) == null ) { throw new IllegalStateException ( "ResourceData#setWriteCallback<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>called<seq2seq4repair_space>for<seq2seq4repair_space>AbstractResource." ) ; } String fileName = data . getFileName ( ) ; ContentDisposition disposition = data . getContentDisposition ( ) ; String mimeType = data . getContentType ( ) ; String encoding = null ; <START_BUG> if ( ( mimeType != null ) && ( ( mimeType . indexOf ( "text" ) ) != ( - 1 ) ) ) { <END_BUG> encoding = data . getTextEncoding ( ) ; } long contentLength = data . getContentLength ( ) ; if ( ( ContentDisposition . ATTACHMENT ) == disposition ) { response . setAttachmentHeader ( fileName ) ; } else if ( ( ContentDisposition . INLINE ) == disposition ) { response . setInlineHeader ( fileName ) ; } if ( mimeType != null ) { if ( encoding == null ) { response . setContentType ( mimeType ) ; } else { response . setContentType ( ( ( mimeType + ";<seq2seq4repair_space>charset=" ) + encoding ) ) ; } } if ( contentLength != ( - 1 ) ) { response . setContentLength ( contentLength ) ; } response . flush ( ) ; data . getWriteCallback ( ) . writeData ( attributes ) ; } public abstract static class WriteCallback { public abstract void writeData ( Attributes attributes ) { } protected final void writeStream ( Attributes attributes , InputStream stream ) { } } }

Fix:
if ( ( mimeType != null ) && ( mimeType . contains ( "text" ) ) ) {