@@ -1450,7 +1450,8 @@ protected final void _writeChunkedString(char[] text, int offset, int len)
1450
1450
* Helper method called when the whole character sequence is known to fit in
1451
1451
* the output buffer regardless of UTF-8 expansion.
1452
1452
*/
1453
- private final int _encode (int outputPtr , char [] str , int i , int end ) {
1453
+ private final int _encode (int outputPtr , char [] str , int i , int end ) throws IOException
1454
+ {
1454
1455
// First: let's see if it's all ASCII: that's rather fast
1455
1456
final byte [] outBuf = _outputBuffer ;
1456
1457
final int outputStart = outputPtr ;
@@ -1470,7 +1471,8 @@ private final int _encode(int outputPtr, char[] str, int i, int end) {
1470
1471
* characters.
1471
1472
*/
1472
1473
private final int _shortUTF8Encode2 (char [] str , int i , int end ,
1473
- int outputPtr , int outputStart ) {
1474
+ int outputPtr , int outputStart ) throws IOException
1475
+ {
1474
1476
final byte [] outBuf = _outputBuffer ;
1475
1477
while (i < end ) {
1476
1478
int c = str [i ++];
@@ -1508,7 +1510,7 @@ private final int _shortUTF8Encode2(char[] str, int i, int end,
1508
1510
return (outputPtr - outputStart );
1509
1511
}
1510
1512
1511
- private final int _encode (int outputPtr , String str , int len ) {
1513
+ private final int _encode (int outputPtr , String str , int len ) throws IOException {
1512
1514
final byte [] outBuf = _outputBuffer ;
1513
1515
final int outputStart = outputPtr ;
1514
1516
@@ -1523,7 +1525,8 @@ private final int _encode(int outputPtr, String str, int len) {
1523
1525
}
1524
1526
1525
1527
private final int _encode2 (int i , int outputPtr , String str , int len ,
1526
- int outputStart ) {
1528
+ int outputStart ) throws IOException
1529
+ {
1527
1530
final byte [] outBuf = _outputBuffer ;
1528
1531
// no; non-ASCII stuff, slower loop
1529
1532
while (i < len ) {
@@ -1562,7 +1565,9 @@ private final int _encode2(int i, int outputPtr, String str, int len,
1562
1565
return (outputPtr - outputStart );
1563
1566
}
1564
1567
1565
- private int _invalidSurrogateStart (int code , byte [] outBuf , int outputPtr ) {
1568
+ private int _invalidSurrogateStart (int code , byte [] outBuf , int outputPtr )
1569
+ throws IOException
1570
+ {
1566
1571
if (isEnabled (Feature .LENIENT_UTF_ENCODING )) {
1567
1572
return _appendReplacementChar (outBuf , outputPtr );
1568
1573
}
@@ -1571,25 +1576,28 @@ private int _invalidSurrogateStart(int code, byte[] outBuf, int outputPtr) {
1571
1576
// but there is no second part to encode
1572
1577
if (code <= SURR1_LAST ) {
1573
1578
// Unmatched first part (closing without second part?)
1574
- throw new IllegalArgumentException (String .format (
1579
+ _reportError (String .format (
1575
1580
"Unmatched surrogate pair, starts with valid high surrogate (0x%04X) but ends without low surrogate" ,
1576
1581
code ));
1577
1582
}
1578
- throw new IllegalArgumentException (String .format (
1583
+ _reportError (String .format (
1579
1584
"Invalid surrogate pair, starts with invalid high surrogate (0x%04X), not in valid range [0xD800, 0xDBFF]" ,
1580
1585
code ));
1586
+ return 0 ; // never gets here
1581
1587
}
1582
1588
1583
1589
private int _invalidSurrogateEnd (int surr1 , int surr2 ,
1584
1590
byte [] outBuf , int outputPtr )
1591
+ throws IOException
1585
1592
{
1586
1593
if (isEnabled (Feature .LENIENT_UTF_ENCODING )) {
1587
1594
return _appendReplacementChar (outBuf , outputPtr );
1588
1595
}
1589
- throw new IllegalArgumentException (String .format (
1596
+ _reportError (String .format (
1590
1597
"Invalid surrogate pair, starts with valid high surrogate (0x%04X)"
1591
1598
+" but ends with invalid low surrogate (0x%04X), not in valid range [0xDC00, 0xDFFF]" ,
1592
1599
surr1 , surr2 ));
1600
+ return 0 ; // never gets here
1593
1601
}
1594
1602
1595
1603
private int _appendReplacementChar (byte [] outBuf , int outputPtr ) {
0 commit comments