eclipse-vertx/vert.x · error · IllegalArgumentException
There is no larger power of 2 int for value:${value} since i
Error message
There is no larger power of 2 int for value:${value} since it exceeds 2^31. What it means
HybridJacksonPool's roundToPowerOfTwo rounds a pool size up to the next power of two, capped at 2^30 (MAX_POW2). Values above the cap cannot be represented as a power-of-two int, so the helper throws IllegalArgumentException stating no larger power of 2 exists below 2^31.
Source
Thrown at vertx-core/src/main/java/io/vertx/core/json/jackson/HybridJacksonPool.java:203
private int probe() {
// Multiplicative Fibonacci hashing implementation
// 0x9e3779b9 is the integral part of the Golden Ratio's fractional part 0.61803398875… (sqrt(5)-1)/2
// multiplied by 2^32, which has the best possible scattering properties.
int probe = (int) ((Thread.currentThread().getId() * 0x9e3779b9) & Integer.MAX_VALUE);
// xorshift
probe ^= probe << 13;
probe ^= probe >>> 17;
probe ^= probe << 5;
return probe;
}
}
private static final int MAX_POW2 = 1 << 30;
private static int roundToPowerOfTwo(final int value) {
if (value > MAX_POW2) {
throw new IllegalArgumentException(
"There is no larger power of 2 int for value:" + value + " since it exceeds 2^31.");
}
if (value < 0) {
throw new IllegalArgumentException("Given value:" + value + ". Expecting value >= 0.");
}
final int nextPow2 = 1 << (32 - Integer.numberOfLeadingZeros(value - 1));
return nextPow2;
}
}
View on GitHub (pinned to fb308bd8c3)
Solutions
- Cap the pool size at 1 << 30 before construction: Math.min(value, 1 << 30)
- Correct the misconfigured size property to a sane value (e.g. CPU count)
- Validate user/config-supplied sizes against the 2^30 limit before passing them to the pool
Example fix
// before
int stripes = Integer.getInteger("pool.stripes", 16) * 1_000_000; // exceeds 2^30
new StripedLockFreePool(stripes);
// after
int stripes = Math.min(1 << 30, Math.max(1, Integer.getInteger("pool.stripes", 16)));
new StripedLockFreePool(stripes); Defensive patterns
Strategy: validation
Validate before calling
if (value > (1 << 30)) throw new IllegalArgumentException("pool size must be <= 2^30"); Try / catch
try {
pool = new HybridJacksonPool.StripedLockFreePool(rawSize);
} catch (IllegalArgumentException e) {
pool = new HybridJacksonPool.StripedLockFreePool(1024);
} Prevention
- Sanity-check any configured pool size against realistic bounds (< 2^30)
- Watch for unit mix-ups (bytes vs count) in size properties
- Cap user-supplied sizes: Math.min(value, 1 << 30)
When it happens
Trigger: Constructing StripedLockFreePool with stripesCount > 2^30 (1,073,741,824), which roundToPowerOfTwo then rejects — usually from an absurdly large configured pool size.
Common situations: Typo in a size system property (e.g. passing bytes instead of count); misconfigured property like 107374182400; unbounded computation like Integer.MAX_VALUE used as pool size.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Expecting a stripesCount that is larger than 0
- Given value:${value}. Expecting value >= 0.
- Expecting a stripesCount that is larger than 0
- workerPoolSize must be > 0
- Can't register a system codec
AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06).
Data as JSON: /api/errors/54105fd7621da3b7.
Report an issue: GitHub.