-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
None
In AWS, we have customer reporting the NumberFormatException threw and caught by java.net.URI.create in some specific cases, see the details here https://github.com/aws/aws-sdk-java-v2/issues/5933
In fact in AWS, it is very common to see account id in the URI like: "https://98765432101.ddb.us-east-1.amazonaws.com", URI#Parser always try to scan ipv4 address first when it parse the server from the string(https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/net/URI.java#L3354-L3396), when it scan ipv4 address the account id will cause NumberFormatException threw from Integer.parseInt called by URI#Parser#scanByte (https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/net/URI.java#L3423-L3431).
In JMH benchmark, the NumberFormatException cloud lead to ~4x worse performance, but overall it should be easy and worth to fix in URI parser.
JMH benchmark our team run to verify the performance:
```
@Benchmark
public void uriCreateAccountIdEndpoint(Blackhole blackhole) {
blackhole.consume(URI.create("https://98765432101.ddb.us-east-1.amazonaws.com"));
}
@Benchmark
public void uriCreateStandardEndpoint(Blackhole blackhole) {
blackhole.consume(URI.create("https://dynamodb.us-east-1.amazonaws.com"));
}
```
Result:
```
Benchmark Mode Cnt Score Error Units
uriCreateAccountIdEndpoint thrpt 10 0.311 ± 0.008 ops/us
uriCreateStandardEndpoint thrpt 10 1.222 ± 0.004 ops/us
uriCreateAccountIdEndpoint avgt 10 3.218 ± 0.115 us/op
uriCreateStandardEndpoint avgt 10 0.830 ± 0.001 us/op
```
In fact in AWS, it is very common to see account id in the URI like: "https://98765432101.ddb.us-east-1.amazonaws.com", URI#Parser always try to scan ipv4 address first when it parse the server from the string(https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/net/URI.java#L3354-L3396), when it scan ipv4 address the account id will cause NumberFormatException threw from Integer.parseInt called by URI#Parser#scanByte (https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/net/URI.java#L3423-L3431).
In JMH benchmark, the NumberFormatException cloud lead to ~4x worse performance, but overall it should be easy and worth to fix in URI parser.
JMH benchmark our team run to verify the performance:
```
@Benchmark
public void uriCreateAccountIdEndpoint(Blackhole blackhole) {
blackhole.consume(URI.create("https://98765432101.ddb.us-east-1.amazonaws.com"));
}
@Benchmark
public void uriCreateStandardEndpoint(Blackhole blackhole) {
blackhole.consume(URI.create("https://dynamodb.us-east-1.amazonaws.com"));
}
```
Result:
```
Benchmark Mode Cnt Score Error Units
uriCreateAccountIdEndpoint thrpt 10 0.311 ± 0.008 ops/us
uriCreateStandardEndpoint thrpt 10 1.222 ± 0.004 ops/us
uriCreateAccountIdEndpoint avgt 10 3.218 ± 0.115 us/op
uriCreateStandardEndpoint avgt 10 0.830 ± 0.001 us/op
```