redis/jedis · error · IllegalArgumentException

Stream entry deletion result value cannot be null

Error message

Stream entry deletion result value cannot be null

What it means

StreamEntryDeletionResult.fromLong requires a non-null Long because a null means the server never returned a deletion result. Passing null is a programming error (missing reply, misparsed response, or caller passing an unset variable), so it fails fast with IllegalArgumentException.

Solutions

  1. Null-check the Redis reply before calling fromLong and handle the nil case explicitly
  2. Verify the command actually succeeded (check pipeline/transaction replies for errors) before mapping its result
  3. Only call fromLong on replies that are known Long values from XDELEX/XACKDEL

Example fix

// before
StreamEntryDeletionResult r = StreamEntryDeletionResult.fromLong(reply);
// after
StreamEntryDeletionResult r = reply == null
    ? StreamEntryDeletionResult.NOT_FOUND
    : StreamEntryDeletionResult.fromLong(reply);
Defensive patterns

Strategy: type-guard

Validate before calling

if (reply != null) {
  StreamEntryDeletionResult r = StreamEntryDeletionResult.fromLong(reply);
} else {
  // handle nil reply explicitly
}

Type guard

boolean hasDeletionResult(Long reply) { return reply != null; }

Prevention

When it happens

Trigger: Calling fromLong(null) directly, or feeding a null builder/parse result (e.g. a missing reply element from a pipeline or transaction response) into fromLong.

Common situations: Pipelined/transactional responses where a reply slot is nil; custom response assembly code that maps results positionally and gets null for a failed command.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/07af921200430dad. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/resps/StreamEntryDeletionResult.java:79

        return NOT_FOUND;
      case 1:
        return DELETED;
      case 2:
        return NOT_DELETED_UNACKNOWLEDGED_OR_STILL_REFERENCED;
      default:
        throw new IllegalArgumentException("Unknown stream entry deletion result code: " + code);
    }
  }

  /**
   * Creates a StreamEntryDeletionResult from a Long value returned by Redis.
   * @param value the Long value from Redis
   * @return the corresponding StreamEntryDeletionResult
   * @throws IllegalArgumentException if the value is null or not recognized
   */
  public static StreamEntryDeletionResult fromLong(Long value) {
    if (value == null) {
      throw new IllegalArgumentException("Stream entry deletion result value cannot be null");
    }
    return fromCode(value.intValue());
  }

  @Override
  public String toString() {
    return name() + "(" + code + ")";
  }
}

View on GitHub (pinned to 6dac31d4c2)