{"record":{"id":"c25c5aace40116a9","repo":"eclipse-vertx/vert.x","slug":"expecting-a-stripescount-that-is-larger-than-0","errorCode":null,"errorMessage":"Expecting a stripesCount that is larger than 0","messagePattern":"Expecting a stripesCount that is larger than 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/json/jackson/HybridJacksonPool.java","lineNumber":88,"sourceCode":"    }\n    // the native thread pool is based on ThreadLocal, so it doesn't have anything to do on release\n  }\n\n  public static class StripedLockFreePool implements RecyclerPool<BufferRecycler> {\n\n    private static final int CACHE_LINE_SHIFT = 4;\n\n    private static final int CACHE_LINE_PADDING = 1 << CACHE_LINE_SHIFT;\n\n    private final XorShiftThreadProbe threadProbe;\n\n    private final AtomicReferenceArray<Node> topStacks;\n\n    private final int stripesCount;\n\n    public StripedLockFreePool(int stripesCount) {\n      if (stripesCount <= 0) {\n        throw new IllegalArgumentException(\"Expecting a stripesCount that is larger than 0\");\n      }\n\n      this.stripesCount = stripesCount;\n      int size = roundToPowerOfTwo(stripesCount);\n      this.topStacks = new AtomicReferenceArray<>(size * CACHE_LINE_PADDING);\n\n      int mask = (size - 1) << CACHE_LINE_SHIFT;\n      this.threadProbe = new XorShiftThreadProbe(mask);\n    }\n\n    public int size() {\n      return stackSizes().sum();\n    }\n\n    public int[] stackStats() {\n      return stackSizes().toArray();\n    }\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/json/jackson/HybridJacksonPool.java#L70-L106","documentation":"The internal StripedLockFreePool of Vert.x's HybridJacksonPool (the reusable parser pool behind the JSON DatabindCodec) requires a positive stripe count. Constructing it with 0 or a negative value fails fast with IllegalArgumentException, since striping with no stripes is meaningless.","triggerScenarios":"Instantiating HybridJacksonPool.StripedLockFreePool with stripesCount <= 0 — typically via custom pool sizing configuration (e.g. a capacity/threads-derived system property resolving to 0 or negative) or direct misuse of the internal class.","commonSituations":"Setting a system property such as vertx.jacksonPool size to 0 or a negative number; computing pool size from Runtime.getRuntime().availableProcessors() on an exotic/containerized JVM that reports 0; tests constructing the pool directly with 0.","solutions":["Fix the configuration/property feeding the stripe count to be >= 1","Clamp computed sizes: Math.max(1, computedSize) before constructing the pool","Use the default HybridJacksonPool configuration instead of overriding it","If constructing directly in tests, pass a positive value (e.g. number of CPUs)"],"exampleFix":"// before\nint stripes = Integer.getInteger(\"pool.stripes\", 0);\nnew StripedLockFreePool(stripes); // IllegalArgumentException\n// after\nint stripes = Math.max(1, Integer.getInteger(\"pool.stripes\", Runtime.getRuntime().availableProcessors()));\nnew StripedLockFreePool(stripes);","handlingStrategy":"validation","validationCode":"if (stripesCount <= 0) throw new IllegalArgumentException(\"stripesCount must be > 0\");\nnew HybridJacksonPool.StripedLockFreePool(stripesCount);","typeGuard":null,"tryCatchPattern":"try {\n  pool = new HybridJacksonPool.StripedLockFreePool(stripes);\n} catch (IllegalArgumentException e) {\n  pool = new HybridJacksonPool.StripedLockFreePool(Runtime.getRuntime().availableProcessors());\n}","preventionTips":["Never configure pool sizes to 0 or negative values","Clamp derived sizes with Math.max(1, n) before constructing","Beware availableProcessors() reporting 0/odd values in exotic container JVMs"],"tags":["illegal-argument","pool","initialization","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"}