Avoid constructing URI (#7293)
Resolves #6568 (Reactor Netty optimization was already implemented in #6600)
This commit is contained in:
parent
52cfafc44a
commit
f9c2c80ef7
|
@ -8,7 +8,6 @@ package io.opentelemetry.instrumentation.grpc.v1_6;
|
|||
import io.grpc.Metadata;
|
||||
import io.grpc.MethodDescriptor;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class GrpcRequest {
|
||||
|
@ -36,12 +35,16 @@ public final class GrpcRequest {
|
|||
if (authority == null) {
|
||||
return;
|
||||
}
|
||||
int index = authority.indexOf(':');
|
||||
if (index == -1) {
|
||||
logicalHost = authority;
|
||||
} else {
|
||||
logicalHost = authority.substring(0, index);
|
||||
try {
|
||||
URI uri = new URI(null, authority, null, null, null);
|
||||
logicalHost = uri.getHost();
|
||||
logicalPort = uri.getPort();
|
||||
} catch (Throwable e) {
|
||||
// do nothing
|
||||
logicalPort = Integer.parseInt(authority.substring(index + 1));
|
||||
} catch (NumberFormatException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue