{"record":{"id":"3b11626c1a413687","repo":"aeron-io/aeron","slug":"term-length-less-than-min-length-of-term-min-length-length","errorCode":null,"errorMessage":"Term length less than min length of {TERM_MIN_LENGTH}: length={termLength}","messagePattern":"Term length less than min length of (.+?): length=(.+?)","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/logbuffer/LogBufferDescriptor.java","lineNumber":456,"sourceCode":"\n        LOG_META_DATA_LENGTH = PAGE_MIN_SIZE;\n    }\n\n    private LogBufferDescriptor()\n    {\n    }\n\n    /**\n     * Check that term length is valid and alignment is valid.\n     *\n     * @param termLength to be checked.\n     * @throws IllegalStateException if the length is not as expected.\n     */\n    public static void checkTermLength(final int termLength)\n    {\n        if (termLength < TERM_MIN_LENGTH)\n        {\n            throw new IllegalStateException(\n                \"Term length less than min length of \" + TERM_MIN_LENGTH + \": length=\" + termLength);\n        }\n\n        if (termLength > TERM_MAX_LENGTH)\n        {\n            throw new IllegalStateException(\n                \"Term length more than max length of \" + TERM_MAX_LENGTH + \": length=\" + termLength);\n        }\n\n        if (!BitUtil.isPowerOfTwo(termLength))\n        {\n            throw new IllegalStateException(\"Term length not a power of 2: length=\" + termLength);\n        }\n    }\n\n    /**\n     * Check that page size is valid and alignment is valid.\n     *","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/logbuffer/LogBufferDescriptor.java#L438-L474","documentation":"LogBufferDescriptor.checkTermLength enforces Aeron's allowed term-buffer size range: below TERM_MIN_LENGTH (64KB) a term buffer cannot implement the log buffer protocol correctly, so an IllegalStateException is thrown. It is a configuration sanity check applied whenever a term length is set or a log is created.","triggerScenarios":"Setting Context/publication termLength (or system property aeron.term.buffer.length) below 64KB, e.g. to 32KB or 4096, before creating a publication or image.","commonSituations":"Trying to shrink memory footprint for embedded/CI environments with an unsupported small value, copying a config from another messaging library, or mistaking KB for bytes (e.g. 64 instead of 65536).","solutions":["Raise the term length to at least LogBufferDescriptor.TERM_MIN_LENGTH (65536 bytes).","Use Aeron's named constants: Context.publicationTermLength(TERM_MIN_LENGTH) or property aeron.term.buffer.length=64k.","If memory is a concern, keep the minimum term length and reduce via other means (sparse files via aeron.term.buffer.sparse=true)."],"exampleFix":"// before\nctx.publicationTermLength(32 * 1024); // too small\n// after\nctx.publicationTermLength(LogBufferDescriptor.TERM_MIN_LENGTH); // 65536","handlingStrategy":"validation","validationCode":"if (termLength < LogBufferDescriptor.TERM_MIN_LENGTH || termLength > LogBufferDescriptor.TERM_MAX_LENGTH) { throw new IllegalArgumentException(\"termLength out of range\"); }","typeGuard":null,"tryCatchPattern":"try { LogBufferDescriptor.checkTermLength(termLength); ctx.publicationTermLength(termLength); } catch (IllegalStateException e) { /* clamp to TERM_MIN_LENGTH */ }","preventionTips":["Use TERM_MIN_LENGTH/TERM_MAX_LENGTH constants, not magic numbers","Remember 64k notation in aeron.term.buffer.length","Don't copy term-length configs from other systems","If memory constrained, use sparse term buffers instead of smaller lengths"],"tags":["aeron","configuration","logbuffer"],"backgroundTag":"value-out-of-range","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}