eclipse-vertx/vert.x · error · UnsupportedOperationException

Unmodifiable stream priority

Error message

Unmodifiable stream priority

What it means

HttpUtils.DEFAULT_STREAM_PRIORITY is an immutable StreamPriority sentinel shared by Vert.x for streams with no explicit priority. Its setters throw UnsupportedOperationException to prevent mutating the shared instance. Calling setWeight on this sentinel means code is attempting to modify an object it does not own.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/http/impl/HttpUtils.java:195

      if (index == 0) {
        return "http.response.status_code";
      }
      throw new IndexOutOfBoundsException("Invalid tag index " + index);
    }

    @Override
    public String value(HttpResponse resp, int index) {
      if (index == 0) {
        return Integer.toString(resp.statusCode());
      }
      throw new IndexOutOfBoundsException("Invalid tag index " + index);
    }
  };

  public static final StreamPriority DEFAULT_STREAM_PRIORITY = new StreamPriority() {
    @Override
    public StreamPriority setWeight(short weight) {
      throw new UnsupportedOperationException("Unmodifiable stream priority");
    }

    @Override
    public StreamPriority setDependency(int dependency) {
      throw new UnsupportedOperationException("Unmodifiable stream priority");
    }

    @Override
    public StreamPriority setExclusive(boolean exclusive) {
      throw new UnsupportedOperationException("Unmodifiable stream priority");
    }
  };


  private HttpUtils() {
  }

  /**

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Create a new StreamPriority, call setWeight on it, then apply it via stream.updatePriority(...)
  2. Never mutate a StreamPriority obtained from an API; treat all returned priorities as read-only copies
  3. If a custom default is needed, build a dedicated instance per use site instead of reusing DEFAULT_STREAM_PRIORITY

Example fix

// before
StreamPriority p = stream.priority();
p.setWeight((short) 32);
// after
StreamPriority p = new StreamPriority().setWeight((short) 32).setDependency(0);
stream.updatePriority(p);
Defensive patterns

Strategy: validation

Validate before calling

if (priority == StreamPriority.DEFAULT_STREAM_PRIORITY) {
  priority = new StreamPriority();
}
priority.setWeight(weight);

Prevention

When it happens

Trigger: Calling setWeight(short) on StreamPriority.DEFAULT_STREAM_PRIORITY, or on a StreamPriority instance obtained from a stream/response that is backed by this unmodifiable default.

Common situations: Retrieving the default priority via a stream's priority() accessor and trying to tune it (e.g. changing HTTP/2 weight) without creating a new StreamPriority object first.

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 eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06). Data as JSON: /api/errors/1f6989c65842bae2. Report an issue: GitHub.