8
8
import com .fasterxml .jackson .core .io .*;
9
9
import com .fasterxml .jackson .core .sym .ByteQuadsCanonicalizer ;
10
10
import com .fasterxml .jackson .core .sym .CharsToNameCanonicalizer ;
11
+ import com .fasterxml .jackson .core .util .VersionUtil ;
11
12
12
13
/**
13
14
* This class is used to determine the encoding of byte stream
@@ -22,7 +23,7 @@ public final class ByteSourceJsonBootstrapper
22
23
public final static byte UTF8_BOM_2 = (byte ) 0xBB ;
23
24
public final static byte UTF8_BOM_3 = (byte ) 0xBF ;
24
25
25
- // [jackson-core#488 ] Limit in bytes for input byte array length to use StringReader instead of InputStreamReader
26
+ // [jackson-core#1081 ] Limit in bytes for input byte array length to use StringReader instead of InputStreamReader
26
27
private static final int STRING_READER_BYTE_ARRAY_LENGTH_LIMIT = 8192 ;
27
28
28
29
/*
@@ -175,7 +176,8 @@ public JsonEncoding detectEncoding() throws IOException
175
176
break ;
176
177
case 4 : enc = _bigEndian ? JsonEncoding .UTF32_BE : JsonEncoding .UTF32_LE ;
177
178
break ;
178
- default : throw new RuntimeException ("Internal error" ); // should never get here
179
+ default :
180
+ return VersionUtil .throwInternalReturnAny ();
179
181
}
180
182
}
181
183
_context .setEncoding (enc );
@@ -235,15 +237,14 @@ public Reader constructReader() throws IOException
235
237
if (in == null ) {
236
238
int length = _inputEnd - _inputPtr ;
237
239
if (length <= STRING_READER_BYTE_ARRAY_LENGTH_LIMIT ) {
238
- // [jackson-core#488 ] Avoid overhead of heap ByteBuffer allocated by InputStreamReader
240
+ // [jackson-core#1081 ] Avoid overhead of heap ByteBuffer allocated by InputStreamReader
239
241
// when processing small inputs up to 8KiB.
240
242
return new StringReader (new String (_inputBuffer , _inputPtr , length , enc .getJavaName ()));
241
243
}
242
244
in = new ByteArrayInputStream (_inputBuffer , _inputPtr , _inputEnd );
243
245
} else {
244
- /* Also, if we have any read but unused input (usually true),
245
- * need to merge that input in:
246
- */
246
+ // Also, if we have any read but unused input (usually true),
247
+ // need to merge that input in:
247
248
if (_inputPtr < _inputEnd ) {
248
249
in = new MergedStream (_context , in , _inputBuffer , _inputPtr , _inputEnd );
249
250
}
@@ -254,7 +255,7 @@ public Reader constructReader() throws IOException
254
255
return new UTF32Reader (_context , _in , _inputBuffer , _inputPtr , _inputEnd ,
255
256
_context .getEncoding ().isBigEndian ());
256
257
}
257
- throw new RuntimeException ( "Internal error" ); // should never get here
258
+ return VersionUtil . throwInternalReturnAny ();
258
259
}
259
260
260
261
public JsonParser constructParser (int parserFeatures , ObjectCodec codec ,
@@ -266,9 +267,8 @@ public JsonParser constructParser(int parserFeatures, ObjectCodec codec,
266
267
int bytesProcessed = _inputPtr - prevInputPtr ;
267
268
268
269
if (enc == JsonEncoding .UTF8 ) {
269
- /* and without canonicalization, byte-based approach is not performant; just use std UTF-8 reader
270
- * (which is ok for larger input; not so hot for smaller; but this is not a common case)
271
- */
270
+ // and without canonicalization, byte-based approach is not performant; just use std UTF-8 reader
271
+ // (which is ok for larger input; not so hot for smaller; but this is not a common case)
272
272
if (JsonFactory .Feature .CANONICALIZE_FIELD_NAMES .enabledIn (factoryFeatures )) {
273
273
ByteQuadsCanonicalizer can = rootByteSymbols .makeChild (factoryFeatures );
274
274
return new UTF8StreamJsonParser (_context , parserFeatures , _in , codec , can ,
@@ -535,9 +535,8 @@ private void reportWeirdUCS4(String type) throws IOException {
535
535
*/
536
536
537
537
protected boolean ensureLoaded (int minimum ) throws IOException {
538
- /* Let's assume here buffer has enough room -- this will always
539
- * be true for the limited used this method gets
540
- */
538
+ // Let's assume here buffer has enough room -- this will always
539
+ // be true for the limited used this method gets
541
540
int gotten = (_inputEnd - _inputPtr );
542
541
while (gotten < minimum ) {
543
542
int count ;
0 commit comments