grpc/grpc-java · error · UnsupportedOperationException

Cronet does not support overriding authority

Error message

Cronet does not support overriding authority

What it means

CronetClientStream does not allow overriding the authority of an RPC; the authority is fixed by the underlying CronetEngine request URL. Calling setAuthority on such a stream always throws UnsupportedOperationException.

Source

Thrown at cronet/src/main/java/io/grpc/cronet/CronetClientStream.java:149

    // Tests expect the "plain" deframer behavior, not MigratingDeframer
    // https://github.com/grpc/grpc-java/issues/7140
    optimizeForDirectExecutor();
  }

  @Override
  protected TransportState transportState() {
    return state;
  }

  @Override
  protected Sink abstractClientStreamSink() {
    return sink;
  }

  @Override
  public void setAuthority(String authority) {
    throw new UnsupportedOperationException("Cronet does not support overriding authority");
  }

  /**
   * Returns a copy of {@code callOptions} with {@code annotation} included as one of the Cronet
   * annotation objects. When an RPC is made using a {@link CallOptions} instance returned by this
   * method, the annotation objects will be attached to the underlying Cronet bidirectional stream.
   * When the stream finishes, the user can retrieve the annotation objects via {@link
   * org.chromium.net.RequestFinishedInfo.Listener}.
   *
   * @param annotation the object to attach to the Cronet stream
   */
  static CallOptions withAnnotation(CallOptions callOptions, Object annotation) {
    Collection<Object> existingAnnotations = callOptions.getOption(CRONET_ANNOTATIONS_KEY);
    ArrayList<Object> newAnnotations;
    if (existingAnnotations == null) {
      newAnnotations = new ArrayList<>();
    } else {
      newAnnotations = new ArrayList<>(existingAnnotations);

View on GitHub (pinned to 64daddc1f3)

Solutions

  1. Remove CallOptions.withAuthority(...) from the call options when using Cronet transport.
  2. Configure the correct host/port/URL on the CronetEngine / channel target instead of overriding authority per-call.
  3. Switch to a transport that supports authority override (e.g. Netty or OkHttp) if per-call authority is required.

Example fix

// before
stub.withCallOptions(CallOptions.DEFAULT.withAuthority("proxy.example.com")).callRpc(req);
// after
ManagedChannel ch = CronetChannelBuilder.forAddress("proxy.example.com", 443, engine).build();
Defensive patterns

Strategy: validation

Validate before calling

if (callOptions.getAuthority() != null && isCronetTransport) throw new IllegalArgumentException("Cronet transport does not support authority override");

Prevention

When it happens

Trigger: An RPC carries CallOptions with a custom authority override (CallOptions.withAuthority) or internal code (e.g. name resolvers/proxies) attempts to set the authority on a Cronet transport stream.

Common situations: Using withAuthority() on CallOptions while forcing the Cronet transport; transparent proxy routing setups that rely on authority overrides.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of grpc/grpc-java@64daddc1f3 (2026-09-08). Data as JSON: /api/errors/4bbd1b0fe73c6de4. Report an issue: GitHub.