didi/DoKit · error · IllegalStateException

Priority already set.

Error message

Priority already set.

What it means

Thrown by Request.Builder.priority(Priority) when a priority was already set on this builder. Picasso treats a repeated priority as a likely bug (each call would silently override the previous one), so the second call is rejected with IllegalStateException.

Source

Thrown at Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/Request.java:414

      rotationPivotX = 0;
      rotationPivotY = 0;
      hasRotationPivot = false;
      return this;
    }

    /** Decode the image using the specified config. */
    public Builder config(Bitmap.Config config) {
      this.config = config;
      return this;
    }

    /** Execute request using the specified priority. */
    public Builder priority(Priority priority) {
      if (priority == null) {
        throw new IllegalArgumentException("Priority invalid.");
      }
      if (this.priority != null) {
        throw new IllegalStateException("Priority already set.");
      }
      this.priority = priority;
      return this;
    }

    /**
     * Add a custom transformation to be applied to the image.
     * <p>
     * Custom transformations will always be run after the built-in transformations.
     */
    public Builder transform(com.didichuxing.doraemonkit.picasso.Transformation transformation) {
      if (transformation == null) {
        throw new IllegalArgumentException("Transformation must not be null.");
      }
      if (transformation.key() == null) {
        throw new IllegalArgumentException("Transformation key must not be null.");
      }
      if (transformations == null) {

View on GitHub (pinned to 626827cddb)

Solutions

  1. Set the priority exactly once per request; remove the duplicate call.
  2. If a default is needed, apply it only when none was set (track it in your own wrapper field).
  3. Search your code for '.priority(' appearing twice on the same builder chain.

Example fix

// before
public RequestCreator load(String url) {
  return picasso.load(url).priority(Priority.NORMAL);
}
load(url).priority(Priority.HIGH); // second call throws

// after
public RequestCreator load(String url) {
  return picasso.load(url); // no default priority
}
load(url).priority(Priority.HIGH); // single call
Defensive patterns

Strategy: validation

Validate before calling

// Track whether your code already applied a priority
if (!priorityApplied) { builder.priority(p); priorityApplied = true; }

Prevention

When it happens

Trigger: Calling .priority(Priority.HIGH).priority(Priority.LOW), or priority() being applied in shared setup code and again at the call site.

Common situations: A base helper that sets a default priority, then request-specific code sets another; copy-pasted chains where priority appears twice; loops that reuse and re-configure a builder.

Related errors


AI-assisted analysis of didi/DoKit@626827cddb (2026-08-14). Data as JSON: /api/errors/e55573ed0a9e6d4b. Report an issue: GitHub.