You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/02/01 15:37:48 UTC
[commons-io] branch master updated: In-line constant reference.
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
The following commit(s) were added to refs/heads/master by this push:
new c1fea08 In-line constant reference.
c1fea08 is described below
commit c1fea088d182d1ac3e9ffb4afd596d27d72088f5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Feb 1 10:37:42 2021 -0500
In-line constant reference.
---
.../org/apache/commons/io/input/XmlStreamReader.java | 16 +++++++---------
1 file changed, 7 insertions(+), 9 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 c8f668e..2e8c714 100644
--- a/src/main/java/org/apache/commons/io/input/XmlStreamReader.java
+++ b/src/main/java/org/apache/commons/io/input/XmlStreamReader.java
@@ -70,8 +70,6 @@ import org.apache.commons.io.IOUtils;
* @since 2.0
*/
public class XmlStreamReader extends Reader {
- private static final int BUFFER_SIZE = IOUtils.DEFAULT_BUFFER_SIZE;
-
private static final String UTF_8 = "UTF-8";
private static final String US_ASCII = "US-ASCII";
@@ -188,14 +186,14 @@ public class XmlStreamReader extends Reader {
throws IOException {
String encoding = null;
if (guessedEnc != null) {
- final byte[] bytes = new byte[BUFFER_SIZE];
- inputStream.mark(BUFFER_SIZE);
+ final byte[] bytes = new byte[IOUtils.DEFAULT_BUFFER_SIZE];
+ inputStream.mark(IOUtils.DEFAULT_BUFFER_SIZE);
int offset = 0;
- int max = BUFFER_SIZE;
+ int max = IOUtils.DEFAULT_BUFFER_SIZE;
int c = inputStream.read(bytes, offset, max);
int firstGT = -1;
String xmlProlog = ""; // avoid possible NPE warning (cannot happen; this just silences the warning)
- while (c != -1 && firstGT == -1 && offset < BUFFER_SIZE) {
+ while (c != -1 && firstGT == -1 && offset < IOUtils.DEFAULT_BUFFER_SIZE) {
offset += c;
max -= c;
c = inputStream.read(bytes, offset, max);
@@ -361,7 +359,7 @@ public class XmlStreamReader extends Reader {
throws IOException {
Objects.requireNonNull(inputStream, "inputStream");
this.defaultEncoding = defaultEncoding;
- final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(inputStream, BUFFER_SIZE), false, BOMS);
+ final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(inputStream, IOUtils.DEFAULT_BUFFER_SIZE), false, BOMS);
final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
this.encoding = doRawStream(bom, pis, lenient);
this.reader = new InputStreamReader(pis, encoding);
@@ -467,7 +465,7 @@ public class XmlStreamReader extends Reader {
final boolean lenient, final String defaultEncoding) throws IOException {
Objects.requireNonNull(inputStream, "inputStream");
this.defaultEncoding = defaultEncoding;
- final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(inputStream, BUFFER_SIZE), false, BOMS);
+ final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(inputStream, IOUtils.DEFAULT_BUFFER_SIZE), false, BOMS);
final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
this.encoding = processHttpStream(bom, pis, httpContentType, lenient);
this.reader = new InputStreamReader(pis, encoding);
@@ -520,7 +518,7 @@ public class XmlStreamReader extends Reader {
final String contentType = conn.getContentType();
final InputStream inputStream = conn.getInputStream();
@SuppressWarnings("resource") // managed by the InputStreamReader tracked by this instance
- final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(inputStream, BUFFER_SIZE), false, BOMS);
+ final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(inputStream, IOUtils.DEFAULT_BUFFER_SIZE), false, BOMS);
final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES);
if (conn instanceof HttpURLConnection || contentType != null) {
this.encoding = processHttpStream(bom, pis, contentType, lenient);