@@ -146,8 +146,51 @@ public Map<String, String> headersSafe() {
146146 return headers ;
147147 }
148148
149+ /**
150+ * The grpcCallOption pass to this function will be merged with the default grpcCallOption.
151+ * @param: the grpcCallOption
152+ */
149153 public void setGrpcCallOption (@ Nonnull final GrpcCallOption grpcCallOption ) {
150- this .grpcCallOption = grpcCallOption ;
154+ GrpcCallOption .Builder builder = getDefaultGrpcCallOptsBuilder (grpcCallOption );
155+
156+ if (grpcCallOption .getMaxOutboundMessageSize () != null ) {
157+ builder .withMaxOutboundMessageSize (grpcCallOption .getMaxOutboundMessageSize ());
158+ }
159+
160+ if (grpcCallOption .getExecutor () != null ) {
161+ builder .withExecutor (grpcCallOption .getExecutor ());
162+ }
163+
164+ if (grpcCallOption .getWaitForReady () != null ) {
165+ builder .withWaitForReady ();
166+ }
167+
168+ if (grpcCallOption .getDeadline () != null ) {
169+ builder .withDeadline (grpcCallOption .getDeadline ());
170+ }
171+
172+ if (grpcCallOption .getCompressorName () != null ) {
173+ builder .withCompressorName (grpcCallOption .getCompressorName ());
174+ }
175+
176+ this .grpcCallOption = builder .build ();
177+ }
178+
179+ /**
180+ * @param grpcCallOption the grpcCallOption.
181+ * @return the default grpc builder with some default options
182+ */
183+ @ Nonnull
184+ private static GrpcCallOption .Builder getDefaultGrpcCallOptsBuilder (@ Nonnull final GrpcCallOption grpcCallOption ) {
185+ GrpcCallOption .Builder builder = new GrpcCallOption .Builder ();
186+ if (grpcCallOption .getMaxInboundMessageSize () != null ) {
187+ builder .withMaxInboundMessageSize (grpcCallOption .getMaxInboundMessageSize ());
188+ } else {
189+ // Set this for backward compatibility
190+ builder .withMaxInboundMessageSize (Integer .MAX_VALUE );
191+ }
192+
193+ return builder ;
151194 }
152195
153196 @ Nullable
0 commit comments