@@ -48,15 +48,15 @@ public final class ByteSourceBootstrapper
48
48
/**
49
49
* Underlying InputStream to use for reading content.
50
50
*/
51
- final InputStream _in ;
51
+ protected final InputStream _in ;
52
52
53
53
/*
54
54
/**********************************************************************
55
55
/* Input buffering
56
56
/**********************************************************************
57
57
*/
58
58
59
- final byte [] _inputBuffer ;
59
+ protected final byte [] _inputBuffer ;
60
60
61
61
private int _inputPtr ;
62
62
@@ -68,11 +68,11 @@ public final class ByteSourceBootstrapper
68
68
/**********************************************************************
69
69
*/
70
70
71
- boolean mBigEndian = true ;
72
- int mBytesPerChar = 0 ; // 0 means "dunno yet"
71
+ protected boolean mBigEndian = true ;
72
+ protected int mBytesPerChar = 0 ; // 0 means "dunno yet"
73
73
74
- boolean mHadBOM = false ;
75
- boolean mByteSizeFound = false ;
74
+ protected boolean mHadBOM = false ;
75
+ protected boolean mByteSizeFound = false ;
76
76
77
77
/*
78
78
/**********************************************************************
@@ -164,9 +164,9 @@ public XmlScanner doBootstrap() throws IOException, XMLStreamException
164
164
return new Utf8Scanner (_config ,
165
165
_in , _inputBuffer , _inputPtr , _inputLen );
166
166
} else if (normEnc .startsWith (CharsetNames .CS_UTF32 )) {
167
- /* Since this is such a rare encoding, we'll just create
168
- * a Reader, and dispatch it to reader scanner?
169
- */
167
+ // Since this is such a rare encoding, we'll just create
168
+ // a Reader, and dispatch it to reader scanner?
169
+
170
170
// let's augment with actual endianness info
171
171
if (normEnc == CharsetNames .CS_UTF32 ) {
172
172
normEnc = mBigEndian ? CharsetNames .CS_UTF32BE : CharsetNames .CS_UTF32LE ;
@@ -176,19 +176,17 @@ public XmlScanner doBootstrap() throws IOException, XMLStreamException
176
176
return new ReaderScanner (_config , r );
177
177
}
178
178
179
- /* And finally, if all else fails, we'll also fall back to
180
- * using JDK-provided decoders and ReaderScanner:
181
- */
179
+ // And finally, if all else fails, we'll also fall back to
180
+ // using JDK-provided decoders and ReaderScanner:
182
181
InputStream in = _in ;
183
182
if (_inputPtr < _inputLen ) {
184
- in = new MergedStream (_config , in , _inputBuffer , _inputPtr , _inputLen );
183
+ in = new MergedStream (_config , in , _inputBuffer , _inputPtr , _inputLen ); // lgtm [java/input-resource-leak]
185
184
}
186
185
if (normEnc == CharsetNames .CS_UTF16 ) {
187
186
normEnc = mBigEndian ? CharsetNames .CS_UTF16BE : CharsetNames .CS_UTF16LE ;
188
187
}
189
188
try {
190
- Reader r = new InputStreamReader (in , normEnc );
191
- return new ReaderScanner (_config , r );
189
+ return new ReaderScanner (_config , new InputStreamReader (in , normEnc ));
192
190
} catch (UnsupportedEncodingException usex ) {
193
191
throw new IoStreamException ("Unsupported encoding: " +usex .getMessage ());
194
192
}
@@ -221,9 +219,8 @@ private void determineStreamEncoding()
221
219
| ((_inputBuffer [_inputPtr +2 ] & 0xFF ) << 8 )
222
220
| (_inputBuffer [_inputPtr +3 ] & 0xFF );
223
221
224
- /* Handling of (usually) optional BOM (required for
225
- * multi-byte formats); first 32-bit charsets:
226
- */
222
+ // Handling of (usually) optional BOM (required for
223
+ // multi-byte formats); first 32-bit charsets:
227
224
switch (quartet ) {
228
225
case 0x0000FEFF :
229
226
mBigEndian = true ;
@@ -760,9 +757,8 @@ private void verifyEncoding(String id, int bpc)
760
757
throws XMLStreamException
761
758
{
762
759
if (mByteSizeFound ) {
763
- /* Let's verify that if we matched an encoding, it's the same
764
- * as what was declared...
765
- */
760
+ // Let's verify that if we matched an encoding, it's the same
761
+ // as what was declared...
766
762
if (bpc != mBytesPerChar ) {
767
763
reportXmlProblem ("Declared encoding '" +id +"' uses " +bpc
768
764
+" bytes per character; but physical encoding appeared to use " +mBytesPerChar +"; cannot decode" );
0 commit comments