api: Avoid initializing CallOptions.Builder fields that will be overwritten

The JIT probably cleans this up, but it is a bit confusing and needless.
This commit is contained in:
Eric Anderson 2022-11-17 18:09:43 -08:00
parent df974455ae
commit dceb764385
1 changed files with 10 additions and 3 deletions

View File

@ -41,7 +41,14 @@ public final class CallOptions {
/**
* A blank {@code CallOptions} that all fields are not set.
*/
public static final CallOptions DEFAULT = new Builder().build();
public static final CallOptions DEFAULT;
static {
Builder b = new Builder();
b.customOptions = new Object[0][2];
b.streamTracerFactories = Collections.emptyList();
DEFAULT = b.build();
}
@Nullable
private final Deadline deadline;
@ -92,9 +99,9 @@ public final class CallOptions {
String authority;
CallCredentials credentials;
String compressorName;
Object[][] customOptions = new Object[0][2];
Object[][] customOptions;
// Unmodifiable list
List<ClientStreamTracer.Factory> streamTracerFactories = Collections.emptyList();
List<ClientStreamTracer.Factory> streamTracerFactories;
Boolean waitForReady;
Integer maxInboundMessageSize;
Integer maxOutboundMessageSize;