quarkusio/quarkus · error · IllegalArgumentException
`weights` cannot be `null`
Error message
`weights` cannot be `null`
What it means
ZAggregateArgs.weights(double...) stores per-input weights for ZUNION/ZINTER/WDIFF style aggregate commands. A null varargs array is not meaningful (varargs calls normally pass zero or more values), so the library rejects null explicitly with IllegalArgumentException to surface the mistake at the call site.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/sortedset/ZAggregateArgs.java:30
MIN,
MAX
}
private final List<Double> weights = new ArrayList<>();
private Aggregate aggregate;
/**
* Using the WEIGHTS option, it is possible to specify a multiplication factor for each input sorted set.
* This means that the score of every element in every input sorted set is multiplied by this factor before being
* passed to the aggregation function. When WEIGHTS is not given, the multiplication factors default to 1.
*
* @param weights the weight values
* @return the current {@code ZAggregateArgs}
**/
public ZAggregateArgs weights(double... weights) {
if (weights == null) {
throw new IllegalArgumentException("`weights` cannot be `null`");
}
for (double weight : weights) {
this.weights.add(weight);
}
return this;
}
/**
* With the AGGREGATE option, it is possible to specify how the results of the union are aggregated.
* This option defaults to SUM, where the score of an element is summed across the inputs where it exists.
* When this option is set to either MIN or MAX, the resulting set will contain the minimum or maximum score of
* an element across the inputs where it exists.
*
* @param aggregate the aggregate value
* @return the current {@code ZAggregateArgs}
**/
public ZAggregateArgs aggregate(Aggregate aggregate) {
this.aggregate = aggregate;View on GitHub (pinned to e1c734241f)
Solutions
- Omit the weights() call entirely when no weights are needed
- Pass an empty array: args.weights(new double[0])
- Null-check the source of the array before forwarding it
Example fix
// before
args.weights(pushedWeights); // pushedWeights may be null
// after
if (pushedWeights != null) {
args.weights(pushedWeights);
} Defensive patterns
Strategy: validation
Validate before calling
if (weights != null) args.weights(weights); // or args.weights(new double[0])
Type guard
boolean hasWeights(double[] w) { return w != null && w.length > 0; } Try / catch
try {
args.weights(weights);
} catch (IllegalArgumentException e) {
// fall back to default (no AGGREGATE weights) args
} Prevention
- Don't call weights() when no weighting is desired
- Null-check any weights array coming from config or another API
- Distinguish 'unset' (skip call) from 'empty' (call with empty array)
When it happens
Trigger: Passing an explicit null: args.weights((double[]) null), or passing a possibly-null double[] variable obtained from elsewhere.
Common situations: Null returned from a config lookup or another method and passed straight through; confusion between 'no weights' (don't call weights()) and 'null weights'.
Related errors
- Aggregation + aggregate + not supported
- `pattern` must not be `null`
- `offset` must not be `null`
- The BitFieldType must not be `null`
- `btf` must not be `null`
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/f3ac2bedffd74bf3.
Report an issue: GitHub.