Buggy code:
public class XmlStreamReader extends Reader { private static final int BUFFER_SIZE = 4096 ; private static final String UTF_8 = "UTF-8" ; private static final String US_ASCII = "US-ASCII" ; private static final String UTF_16BE = "UTF-16BE" ; private static final String UTF_16LE = "UTF-16LE" ; private static final String UTF_16 = "UTF-16" ; private static final String EBCDIC = "CP1047" ; private static final ByteOrderMark [ ] BOMS = new ByteOrderMark [ ] { ByteOrderMark . UTF_8 , ByteOrderMark . UTF_16BE , ByteOrderMark . UTF_16LE } ; private static final ByteOrderMark [ ] XML_GUESS_BYTES = new ByteOrderMark [ ] { new ByteOrderMark ( XmlStreamReader . UTF_8 , 60 , 63 , 120 , 109 ) , new ByteOrderMark ( XmlStreamReader . UTF_16BE , 0 , 60 , 0 , 63 ) , new ByteOrderMark ( XmlStreamReader . UTF_16LE , 60 , 0 , 63 , 0 ) , new ByteOrderMark ( XmlStreamReader . EBCDIC , 76 , 111 , 167 , 148 ) } ; private static String staticDefaultEncoding = null ; private Reader reader ; private String encoding ; private String defaultEncoding ; public static void setDefaultEncoding ( String encoding ) { } public static String getDefaultEncoding ( ) { } public XmlStreamReader ( File file ) throws IOException { } public XmlStreamReader ( InputStream is ) throws IOException { } public XmlStreamReader ( InputStream is , boolean lenient ) throws IOException { } public XmlStreamReader ( URL url ) throws IOException { } public XmlStreamReader ( URLConnection conn ) throws IOException { } public XmlStreamReader ( InputStream is , String httpContentType ) throws IOException { } public XmlStreamReader ( InputStream is , String httpContentType , boolean lenient , String defaultEncoding ) throws IOException { } public XmlStreamReader ( InputStream is , String httpContentType , boolean lenient ) throws IOException { } private void doLenientDetection ( String httpContentType , InputStream is , XmlStreamReaderException ex ) throws IOException { } public String getEncoding ( ) { } @ Override public int read ( char [ ] buf , int offset , int len ) throws IOException { } @ Override public void close ( ) throws IOException { } private void doRawStream ( InputStream is , boolean lenient ) throws IOException { } private void doHttpStream ( InputStream is , String httpContentType , boolean lenient ) throws IOException { } String calculateRawEncoding ( String bomEnc , String xmlGuessEnc , String xmlEnc ) throws IOException { if ( bomEnc == null ) { if ( ( xmlGuessEnc == null ) || ( xmlEnc == null ) ) { return ( defaultEncoding ) == null ? XmlStreamReader . UTF_8 : defaultEncoding ; } if ( ( xmlEnc . equals ( XmlStreamReader . UTF_16 ) ) && ( ( xmlGuessEnc . equals ( XmlStreamReader . UTF_16BE ) ) || ( xmlGuessEnc . equals ( XmlStreamReader . UTF_16LE ) ) ) ) { return xmlGuessEnc ; } return xmlEnc ; } if ( bomEnc . equals ( XmlStreamReader . UTF_8 ) ) { if ( ( xmlGuessEnc != null ) && ( ! ( xmlGuessEnc . equals ( XmlStreamReader . UTF_8 ) ) ) ) { String msg = MessageFormat . format ( XmlStreamReader . RAW_EX_1 , new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) ; throw new XmlStreamReaderException ( msg , bomEnc , xmlGuessEnc , xmlEnc ) ; } if ( ( xmlEnc != null ) && ( ! ( xmlEnc . equals ( XmlStreamReader . UTF_8 ) ) ) ) { String msg = MessageFormat . format ( XmlStreamReader . RAW_EX_1 , new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) ; throw new XmlStreamReaderException ( msg , bomEnc , xmlGuessEnc , xmlEnc ) ; } return bomEnc ; } if ( ( bomEnc . equals ( XmlStreamReader . UTF_16BE ) ) || ( bomEnc . equals ( XmlStreamReader . UTF_16LE ) ) ) { if ( ( xmlGuessEnc != null ) && ( ! ( xmlGuessEnc . equals ( bomEnc ) ) ) ) { String msg = MessageFormat . format ( XmlStreamReader . RAW_EX_1 , new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) ; <START_BUG> throw new IOException ( msg ) ; <END_BUG> } if ( ( ( xmlEnc != null ) && ( ! ( xmlEnc . equals ( XmlStreamReader . UTF_16 ) ) ) ) && ( ! ( xmlEnc . equals ( bomEnc ) ) ) ) { String msg = MessageFormat . format ( XmlStreamReader . RAW_EX_1 , new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) ; throw new XmlStreamReaderException ( msg , bomEnc , xmlGuessEnc , xmlEnc ) ; } return bomEnc ; } String msg = MessageFormat . format ( XmlStreamReader . RAW_EX_2 , new Object [ ] { bomEnc , xmlGuessEnc , xmlEnc } ) ; throw new XmlStreamReaderException ( msg , bomEnc , xmlGuessEnc , xmlEnc ) ; } String calculateHttpEncoding ( String httpContentType , String bomEnc , String xmlGuessEnc , String xmlEnc , boolean lenient ) throws IOException { } static String getContentTypeMime ( String httpContentType ) { } private static final Pattern CHARSET_PATTERN = Pattern . compile ( "charset=[\"\']?([.[^;<seq2seq4repair_space>\"\']]*)[\"\']?" ) ; static String getContentTypeEncoding ( String httpContentType ) { } public static final Pattern ENCODING_PATTERN = Pattern . compile ( "<\\?xml.*encoding[\\s]*=[\\s]*((?:\".[^\"]*\")|(?:\'.[^\']*\'))" , Pattern . MULTILINE ) ; private static String getXmlProlog ( InputStream is , String guessedEnc ) throws IOException { } static boolean isAppXml ( String mime ) { } static boolean isTextXml ( String mime ) { } private static final String RAW_EX_1 = "Invalid<seq2seq4repair_space>encoding,<seq2seq4repair_space>BOM<seq2seq4repair_space>[{0}]<seq2seq4repair_space>XML<seq2seq4repair_space>guess<seq2seq4repair_space>[{1}]<seq2seq4repair_space>XML<seq2seq4repair_space>prolog<seq2seq4repair_space>[{2}]<seq2seq4repair_space>encoding<seq2seq4repair_space>mismatch" ; private static final String RAW_EX_2 = "Invalid<seq2seq4repair_space>encoding,<seq2seq4repair_space>BOM<seq2seq4repair_space>[{0}]<seq2seq4repair_space>XML<seq2seq4repair_space>guess<seq2seq4repair_space>[{1}]<seq2seq4repair_space>XML<seq2seq4repair_space>prolog<seq2seq4repair_space>[{2}]<seq2seq4repair_space>unknown<seq2seq4repair_space>BOM" ; private static final String HTTP_EX_1 = "Invalid<seq2seq4repair_space>encoding,<seq2seq4repair_space>CT-MIME<seq2seq4repair_space>[{0}]<seq2seq4repair_space>CT-Enc<seq2seq4repair_space>[{1}]<seq2seq4repair_space>BOM<seq2seq4repair_space>[{2}]<seq2seq4repair_space>XML<seq2seq4repair_space>guess<seq2seq4repair_space>[{3}]<seq2seq4repair_space>XML<seq2seq4repair_space>prolog<seq2seq4repair_space>[{4}],<seq2seq4repair_space>BOM<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>NULL" ; private static final String HTTP_EX_2 = "Invalid<seq2seq4repair_space>encoding,<seq2seq4repair_space>CT-MIME<seq2seq4repair_space>[{0}]<seq2seq4repair_space>CT-Enc<seq2seq4repair_space>[{1}]<seq2seq4repair_space>BOM<seq2seq4repair_space>[{2}]<seq2seq4repair_space>XML<seq2seq4repair_space>guess<seq2seq4repair_space>[{3}]<seq2seq4repair_space>XML<seq2seq4repair_space>prolog<seq2seq4repair_space>[{4}],<seq2seq4repair_space>encoding<seq2seq4repair_space>mismatch" ; private static final String HTTP_EX_3 = "Invalid<seq2seq4repair_space>encoding,<seq2seq4repair_space>CT-MIME<seq2seq4repair_space>[{0}]<seq2seq4repair_space>CT-Enc<seq2seq4repair_space>[{1}]<seq2seq4repair_space>BOM<seq2seq4repair_space>[{2}]<seq2seq4repair_space>XML<seq2seq4repair_space>guess<seq2seq4repair_space>[{3}]<seq2seq4repair_space>XML<seq2seq4repair_space>prolog<seq2seq4repair_space>[{4}],<seq2seq4repair_space>Invalid<seq2seq4repair_space>MIME" ; }

Fix:
throw new XmlStreamReaderException ( msg , bomEnc , xmlGuessEnc , xmlEnc ) ;