This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit 99106fd1670193815411b931556bdc39f86ba9bd Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Tue Jun 21 08:03:20 2022 -0400 Whitespace and name tweaks --- .../apache/commons/io/input/XmlStreamReader.java | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java index 7d666758..0dec7002 100644 --- a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java +++ b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java @@ -98,7 +98,7 @@ public class XmlStreamReader extends Reader { ByteOrderMark.UTF_32LE }; - // UTF_16LE and UTF_32LE have the same two starting BOM bytes. + /** UTF_16LE and UTF_32LE have the same two starting BOM bytes. */ private static final ByteOrderMark[] XML_GUESS_BYTES = { new ByteOrderMark(UTF_8, 0x3C, 0x3F, 0x78, 0x6D), new ByteOrderMark(UTF_16BE, 0x00, 0x3C, 0x00, 0x3F), @@ -453,7 +453,6 @@ public class XmlStreamReader extends Reader { this(inputStream, httpContentType, lenient, null); } - /** * Constructs a Reader using an InputStream and the associated content-type * header. This constructor is lenient regarding the encoding detection. @@ -547,7 +546,6 @@ public class XmlStreamReader extends Reader { * the URL. */ public XmlStreamReader(final URL url) throws IOException { - // TODO URLConnection leak. this(Objects.requireNonNull(url, "url").openConnection(), null); } @@ -580,14 +578,14 @@ public class XmlStreamReader extends Reader { final String contentType = urlConnection.getContentType(); final InputStream inputStream = urlConnection.getInputStream(); @SuppressWarnings("resource") // managed by the InputStreamReader tracked by this instance - final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(inputStream, IOUtils.DEFAULT_BUFFER_SIZE), false, BOMS); - final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES); + final BOMInputStream bomInput = new BOMInputStream(new BufferedInputStream(inputStream, IOUtils.DEFAULT_BUFFER_SIZE), false, BOMS); + final BOMInputStream piInput = new BOMInputStream(bomInput, true, XML_GUESS_BYTES); if (urlConnection instanceof HttpURLConnection || contentType != null) { - this.encoding = processHttpStream(bom, pis, contentType, lenient); + this.encoding = processHttpStream(bomInput, piInput, contentType, lenient); } else { - this.encoding = doRawStream(bom, pis, lenient); + this.encoding = doRawStream(bomInput, piInput, lenient); } - this.reader = new InputStreamReader(pis, encoding); + this.reader = new InputStreamReader(piInput, encoding); } /** @@ -826,21 +824,20 @@ public class XmlStreamReader extends Reader { } /** - * Processes a HTTP stream. + * Processes an HTTP stream. * - * @param bom BOMInputStream to detect byte order marks - * @param pis BOMInputStream to guess XML encoding + * @param bomInput BOMInputStream to detect byte order marks + * @param piInput BOMInputStream to guess XML encoding * @param httpContentType The HTTP content type - * @param lenient indicates if the charset encoding detection should be - * relaxed. + * @param lenient indicates if the charset encoding detection should be relaxed. * @return the encoding to be used * @throws IOException thrown if there is a problem reading the stream. */ - private String processHttpStream(final BOMInputStream bom, final BOMInputStream pis, final String httpContentType, - final boolean lenient) throws IOException { - final String bomEnc = bom.getBOMCharsetName(); - final String xmlGuessEnc = pis.getBOMCharsetName(); - final String xmlEnc = getXmlProlog(pis, xmlGuessEnc); + private String processHttpStream(final BOMInputStream bomInput, final BOMInputStream piInput, final String httpContentType, final boolean lenient) + throws IOException { + final String bomEnc = bomInput.getBOMCharsetName(); + final String xmlGuessEnc = piInput.getBOMCharsetName(); + final String xmlEnc = getXmlProlog(piInput, xmlGuessEnc); try { return calculateHttpEncoding(httpContentType, bomEnc, xmlGuessEnc, xmlEnc, lenient); } catch (final XmlStreamReaderException ex) {