Skip to content

Commit e4540bb

Browse files
author
Niall Pemberton
committed
Refactoring to remove the InputStream from XmlStreamReaderException in r1004109 means we don't need to pass the InputStream to the calculateRawEncoding() and calculateHttpEncoding() methods
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1004512 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3050624 commit e4540bb

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/main/java/org/apache/commons/io/input/XmlStreamReader.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ private void doRawStream(InputStream is, boolean lenient)
448448
String bomEnc = bom.getBOMCharsetName();
449449
String xmlGuessEnc = pis.getBOMCharsetName();
450450
String xmlEnc = getXmlProlog(pis, xmlGuessEnc);
451-
this.encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, pis);
451+
this.encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc);
452452
this.reader = new InputStreamReader(is, encoding);
453453
}
454454

@@ -471,7 +471,7 @@ private void doHttpStream(InputStream is, String httpContentType,
471471
String xmlGuessEnc = pis.getBOMCharsetName();
472472
String xmlEnc = getXmlProlog(pis, xmlGuessEnc);
473473
this.encoding = calculateHttpEncoding(cTMime, cTEnc, bomEnc,
474-
xmlGuessEnc, xmlEnc, pis, lenient);
474+
xmlGuessEnc, xmlEnc, lenient);
475475
this.reader = new InputStreamReader(is, encoding);
476476
}
477477

@@ -481,12 +481,11 @@ private void doHttpStream(InputStream is, String httpContentType,
481481
* @param bomEnc BOM encoding
482482
* @param xmlGuessEnc XML Guess encoding
483483
* @param xmlEnc XML encoding
484-
* @param is InputStream to create the reader from.
485484
* @return the raw encoding
486485
* @throws IOException thrown if there is a problem reading the stream.
487486
*/
488487
private String calculateRawEncoding(String bomEnc, String xmlGuessEnc,
489-
String xmlEnc, InputStream is) throws IOException {
488+
String xmlEnc) throws IOException {
490489
String encoding;
491490
if (bomEnc == null) {
492491
if (xmlGuessEnc == null || xmlEnc == null) {
@@ -535,14 +534,13 @@ private String calculateRawEncoding(String bomEnc, String xmlGuessEnc,
535534
* @param bomEnc BOM encoding
536535
* @param xmlGuessEnc XML Guess encoding
537536
* @param xmlEnc XML encoding
538-
* @param is InputStream to create the reader from.
539537
* @param lenient indicates if the charset encoding detection should be
540538
* relaxed.
541539
* @return the HTTP encoding
542540
* @throws IOException thrown if there is a problem reading the stream.
543541
*/
544542
private String calculateHttpEncoding(String cTMime, String cTEnc,
545-
String bomEnc, String xmlGuessEnc, String xmlEnc, InputStream is,
543+
String bomEnc, String xmlGuessEnc, String xmlEnc,
546544
boolean lenient) throws IOException {
547545
String encoding;
548546
if (lenient & xmlEnc != null) {
@@ -553,8 +551,7 @@ private String calculateHttpEncoding(String cTMime, String cTEnc,
553551
if (appXml || textXml) {
554552
if (cTEnc == null) {
555553
if (appXml) {
556-
encoding = calculateRawEncoding(bomEnc, xmlGuessEnc,
557-
xmlEnc, is);
554+
encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc);
558555
} else {
559556
encoding = (defaultEncoding == null) ? US_ASCII
560557
: defaultEncoding;

0 commit comments

Comments
 (0)