Hi team:

Recently, we noticed that there are hundreds
of ArrayIndexOutOfBoundsExceptions (and deoptimization events) have been
thrown by `HttpParser.readHostIPv4`. It can be reproduced with the
following test case:

```java

@Test
void debugStandardIpv4_isNumericOnEof() throws IOException {
    HttpParser.readHostIPv4(new StringReader("127.0.0.1"), false);
}

```

The method does not throws the exception directly, but rather swallows it
inside `isNumeric` through the following steps:


   1. All characters are read, reaching EOF and returning -1;
   2. The `isNumeric` check is performed before the `-1` check;
   3. `-1` triggers an ArrayIndexOutOfBoundsException inside isNumeric;

[image: image.png]
[image: image.png]

So my question is:

1. Should the `-1` branch be placed before the `isNumeric` branch? or is
there another reason for the current implementation?
2. Should check `0 < c < ARRAY_SIZE`?



Best regards,
Chunhui Liu

Reply via email to