{"record":{"id":"89d2d7e5237a1514","repo":"eclipse-vertx/vert.x","slug":"given-value-value-expecting-value-0","errorCode":null,"errorMessage":"Given value:${value}. Expecting value >= 0.","messagePattern":"Given value:(.+?)\\. Expecting value >= 0\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/json/jackson/HybridJacksonPool.java","lineNumber":207,"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":189,"sourceCodeEnd":213,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/json/jackson/HybridJacksonPool.java#L189-L213","documentation":"roundToPowerOfTwo also guards against negative input: a value below 0 has no power-of-two rounding and triggers IllegalArgumentException 'Given value:X. Expecting value >= 0.' This is a fail-fast precondition inside HybridJacksonPool's pooling helper.","triggerScenarios":"Constructing StripedLockFreePool with a negative stripesCount — e.g. a size property parsed as a negative number, or arithmetic underflow (multiplication/subtraction) producing a negative pool size before the positive check ordering (the > MAX_POW2 check happens first).","commonSituations":"Config file with a negative pool size; computing stripes as users - overhead yielding a negative; parsing errors where '-1' sentinel leaks into configuration.","solutions":["Clamp to non-negative before construction: Math.max(0, value) (then ensure >= 1 for the pool)","Fix the negative value in the size configuration or property source","Add validation at the configuration-parsing boundary to reject negative sizes early"],"exampleFix":"// before\nint stripes = configuredUsers - reserved; // can go negative\nnew StripedLockFreePool(stripes);\n// after\nint stripes = Math.max(1, configuredUsers - reserved);\nnew StripedLockFreePool(stripes);","handlingStrategy":"validation","validationCode":"if (value < 0) throw new IllegalArgumentException(\"pool size must be >= 0\");","typeGuard":null,"tryCatchPattern":"try {\n  pool = new HybridJacksonPool.StripedLockFreePool(rawSize);\n} catch (IllegalArgumentException e) {\n  pool = new HybridJacksonPool.StripedLockFreePool(16);\n}","preventionTips":["Validate numeric config values' sign at parse time","Guard derived arithmetic (subtraction/multiplication) against underflow","Treat -1 sentinels explicitly instead of passing them through"],"tags":["illegal-argument","pool","negative-value","jackson"],"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"}