-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b14
```
private int scanIPv4Address(int start, int n, boolean strict)
throws URISyntaxException
{
int p = start;
int q;
int m = scan(p, n, L_DIGIT | L_DOT, H_DIGIT | H_DOT);
if ((m <= p) || (strict && (m != n)))
return -1;
for (;;) {
// Per RFC2732: At most three digits per byte
// Further constraint: Each element fits in a byte
if ((q = scanByte(p, m)) <= p) break; p = q;
if ((q = scan(p, m, '.')) <= p) break; p = q;
if ((q = scanByte(p, m)) <= p) break; p = q;
if ((q = scan(p, m, '.')) <= p) break; p = q;
if ((q = scanByte(p, m)) <= p) break; p = q;
if ((q = scan(p, m, '.')) <= p) break; p = q;
if ((q = scanByte(p, m)) <= p) break; p = q;
if (q < m) break;
return q;
}
fail("Malformed IPv4 address", q);
return -1;
}
```
Looking into cpu profile data of one of our system, noticed the URISyntaxException threw at fail("Malformed IPv4 address", q) used about 0.3% CPU, we could add `-XX:+OmitStackTraceInFastThrow`, but after further looking into URI code, we think it should be fixed in JDK.
private int scanIPv4Address(int start, int n, boolean strict)
throws URISyntaxException
{
int p = start;
int q;
int m = scan(p, n, L_DIGIT | L_DOT, H_DIGIT | H_DOT);
if ((m <= p) || (strict && (m != n)))
return -1;
for (;;) {
// Per RFC2732: At most three digits per byte
// Further constraint: Each element fits in a byte
if ((q = scanByte(p, m)) <= p) break; p = q;
if ((q = scan(p, m, '.')) <= p) break; p = q;
if ((q = scanByte(p, m)) <= p) break; p = q;
if ((q = scan(p, m, '.')) <= p) break; p = q;
if ((q = scanByte(p, m)) <= p) break; p = q;
if ((q = scan(p, m, '.')) <= p) break; p = q;
if ((q = scanByte(p, m)) <= p) break; p = q;
if (q < m) break;
return q;
}
fail("Malformed IPv4 address", q);
return -1;
}
```
Looking into cpu profile data of one of our system, noticed the URISyntaxException threw at fail("Malformed IPv4 address", q) used about 0.3% CPU, we could add `-XX:+OmitStackTraceInFastThrow`, but after further looking into URI code, we think it should be fixed in JDK.
- links to
-
Commit(master) openjdk/jdk/a90f323d
-
Review(master) openjdk/jdk/23538