Skip to content

Commit ebc9add

Browse files
committed
Avoid allocating empty array in LoadBalancer
Use a singleton empty Object array to initialize the customOptions default in LoadBalancer.Builder.
1 parent 5a54372 commit ebc9add

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

api/src/main/java/io/grpc/LoadBalancer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,11 @@ public String toString() {
855855
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771")
856856
public static final class Builder {
857857

858+
private static final Object[][] EMPTY_CUSTOM_OPTIONS = new Object[0][2];
859+
858860
private List<EquivalentAddressGroup> addrs;
859861
private Attributes attrs = Attributes.EMPTY;
860-
private Object[][] customOptions = new Object[0][2];
862+
private Object[][] customOptions = EMPTY_CUSTOM_OPTIONS;
861863

862864
Builder() {
863865
}

0 commit comments

Comments
 (0)