{"record":{"id":"f8abea8be56f2a9b","repo":"eclipse-vertx/vert.x","slug":"given-value","errorCode":null,"errorMessage":"Given value:","messagePattern":"Given value:","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java21/io/vertx/core/json/jackson/v3/HybridJacksonPool.java","lineNumber":205,"sourceCode":"      // 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":187,"sourceCodeEnd":211,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java21/io/vertx/core/json/jackson/v3/HybridJacksonPool.java#L187-L211","documentation":"HybridJacksonPool.roundToPowerOfTwo validates pool sizing arguments before rounding them to the next power of two. It throws IllegalArgumentException when the value exceeds the maximum representable power of two (2^31 as an int, capped by MAX_POW2) or when the value is negative. It is an internal guard that signals invalid capacity arguments, not a JSON data problem.","triggerScenarios":"Calling pool/queue sizing APIs (e.g. HybridJacksonPool factory methods or underlying VertxPool arguments) with a capacity greater than MAX_POW2 (over 2^31 as an int) or with a negative number such as a negative initial size passed to a pooled parser factory.","commonSituations":"Configuration files where a pool-size or buffer-capacity property is computed (e.g. a size derived from another value becoming negative due to an int overflow), or copy-pasted configuration using bytes as the unit when the API expects a small count.","solutions":["Verify the value passed to the pool-sizing API is non-negative and <= MAX_POW2 (2^31 as an int is the practical cap)","Clamp or validate the configured size before passing it: Math.max(0, Math.min(value, MAX_POW2))","Fix the configuration/derivation that produced a negative or oversized value (e.g. check for int overflow in size computation)"],"exampleFix":"// before\nint size = Integer.getInteger(\"pool.size\", -1);\nJsonPool pool = HybridJacksonPool.getInstance(size); // IllegalArgumentException\n// after\nint size = Integer.getInteger(\"pool.size\", 16);\nif (size < 0 || size > HybridJacksonPool.MAX_POW2) size = 16;\nJsonPool pool = HybridJacksonPool.getInstance(size);","handlingStrategy":"validation","validationCode":"if (value < 0 || value > MAX_POW2) {\n  throw new IllegalArgumentException(\"pool size out of range: \" + value);\n}\nJsonPool pool = HybridJacksonPool.getInstance(value);","typeGuard":"static boolean isValidPoolSize(int v) { return v >= 0 && v <= (1 << 30); }","tryCatchPattern":null,"preventionTips":["Validate configured pool sizes at startup, fail fast with a clear message","Never compute pool sizes from unvalidated user input or unchecked arithmetic (watch for int overflow)","Clamp sizes to a safe maximum instead of passing them raw"],"tags":["java","configuration","pool-sizing"],"backgroundTag":"invalid-argument-value","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"}