{"record":{"id":"54105fd7621da3b7","repo":"eclipse-vertx/vert.x","slug":"there-is-no-larger-power-of-2-int-for-value-valu","errorCode":null,"errorMessage":"There is no larger power of 2 int for value:${value} since it exceeds 2^31.","messagePattern":"There is no larger power of 2 int for value:(.+?) since it exceeds 2\\^31\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/json/jackson/HybridJacksonPool.java","lineNumber":203,"sourceCode":"\n    private int probe() {\n      // Multiplicative Fibonacci hashing implementation\n      // 0x9e3779b9 is the integral part of the Golden Ratio's fractional part 0.61803398875… (sqrt(5)-1)/2\n      // multiplied by 2^32, which has the best possible scattering properties.\n      int probe = (int) ((Thread.currentThread().getId() * 0x9e3779b9) & Integer.MAX_VALUE);\n      // xorshift\n      probe ^= probe << 13;\n      probe ^= probe >>> 17;\n      probe ^= probe << 5;\n      return probe;\n    }\n  }\n\n  private static final int MAX_POW2 = 1 << 30;\n\n  private static int roundToPowerOfTwo(final int value) {\n    if (value > MAX_POW2) {\n      throw new IllegalArgumentException(\n        \"There is no larger power of 2 int for value:\" + value + \" since it exceeds 2^31.\");\n    }\n    if (value < 0) {\n      throw new IllegalArgumentException(\"Given value:\" + value + \". Expecting value >= 0.\");\n    }\n    final int nextPow2 = 1 << (32 - Integer.numberOfLeadingZeros(value - 1));\n    return nextPow2;\n  }\n}\n","sourceCodeStart":185,"sourceCodeEnd":213,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/json/jackson/HybridJacksonPool.java#L185-L213","documentation":"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.","triggerScenarios":"Constructing StripedLockFreePool with stripesCount > 2^30 (1,073,741,824), which roundToPowerOfTwo then rejects — usually from an absurdly large configured pool size.","commonSituations":"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.","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"],"exampleFix":"// before\nint stripes = Integer.getInteger(\"pool.stripes\", 16) * 1_000_000; // exceeds 2^30\nnew StripedLockFreePool(stripes);\n// after\nint stripes = Math.min(1 << 30, Math.max(1, Integer.getInteger(\"pool.stripes\", 16)));\nnew StripedLockFreePool(stripes);","handlingStrategy":"validation","validationCode":"if (value > (1 << 30)) throw new IllegalArgumentException(\"pool size must be <= 2^30\");","typeGuard":null,"tryCatchPattern":"try {\n  pool = new HybridJacksonPool.StripedLockFreePool(rawSize);\n} catch (IllegalArgumentException e) {\n  pool = new HybridJacksonPool.StripedLockFreePool(1024);\n}","preventionTips":["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)"],"tags":["illegal-argument","pool","power-of-two","jackson"],"backgroundTag":"value-out-of-range","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}