{"record":{"id":"6ee248b3c3713c5c","repo":"aeron-io/aeron","slug":"invalid-idle-sleep-duration-idlesleepdurationns-ns","errorCode":null,"errorMessage":"Invalid idle sleep duration: <idleSleepDurationNs>ns","messagePattern":"Invalid idle sleep duration: <idleSleepDurationNs>ns","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/Aeron.java","lineNumber":1213,"sourceCode":"\n            if (clientName.length() > MAX_CLIENT_NAME_LENGTH)\n            {\n                throw new ConfigurationException(\"clientName length must <= \" + MAX_CLIENT_NAME_LENGTH);\n            }\n\n            if (null == epochClock)\n            {\n                epochClock = SystemEpochClock.INSTANCE;\n            }\n\n            if (null == nanoClock)\n            {\n                nanoClock = SystemNanoClock.INSTANCE;\n            }\n\n            if (idleSleepDurationNs < 0 || idleSleepDurationNs > TimeUnit.SECONDS.toNanos(1))\n            {\n                throw new ConfigurationException(\"Invalid idle sleep duration: \" + idleSleepDurationNs + \"ns\");\n            }\n\n            if (null == idleStrategy)\n            {\n                idleStrategy = new SleepingMillisIdleStrategy(TimeUnit.NANOSECONDS.toMillis(idleSleepDurationNs));\n            }\n\n            if (null == awaitingIdleStrategy)\n            {\n                awaitingIdleStrategy = new SleepingMillisIdleStrategy(Configuration.AWAITING_IDLE_SLEEP_MS);\n            }\n\n            connectToDriver();\n            filePageSize = driverFilePageSize(cncMetaDataBuffer);\n\n            interServiceTimeoutNs = CncFileDescriptor.clientLivenessTimeoutNs(cncMetaDataBuffer);\n            if (interServiceTimeoutNs <= keepAliveIntervalNs)\n            {","sourceCodeStart":1195,"sourceCodeEnd":1231,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/Aeron.java#L1195-L1231","documentation":"Aeron.Context throws this ConfigurationException when idleSleepDurationNs is negative or greater than 1 second. This value configures the SleepingMillisIdleStrategy used by the client conductor when no work is available, so it must be a sane sleep duration within [0, 1s].","triggerScenarios":"Calling ctx.idleSleepDurationNs(ns) with ns < 0 or ns > TimeUnit.SECONDS.toNanos(1), then Aeron.connect(ctx); loading the value from a config property without clamping (e.g. a mistyped value like -1 or 10_000_000_000).","commonSituations":"External configuration files where the duration was entered in milliseconds instead of nanoseconds (value far above 1s); sign errors when tuning idle behavior; copying a duration computed for another purpose.","solutions":["Set idleSleepDurationNs to a value between 0 and 1_000_000_000 nanoseconds","Clamp or validate the value read from configuration before passing it to the Context","Use a different IdleStrategy via ctx.idleStrategy(...) if sub-millisecond or longer sleeps are needed"],"exampleFix":"// before\nctx.idleSleepDurationNs(Long.parseLong(props.getProperty(\"idle.ns\"))); // e.g. 10000000000 -> throws\n// after\nlong ns = Long.parseLong(props.getProperty(\"idle.ns\"));\nns = Math.max(0, Math.min(ns, TimeUnit.SECONDS.toNanos(1)));\nctx.idleSleepDurationNs(ns);","handlingStrategy":"validation","validationCode":"if (ns < 0 || ns > TimeUnit.SECONDS.toNanos(1)) { throw new IllegalArgumentException(\"idleSleepDurationNs out of range: \" + ns); }","typeGuard":"long clampIdleNs(long ns) { return Math.max(0, Math.min(ns, TimeUnit.SECONDS.toNanos(1))); }","tryCatchPattern":"try { ctx.idleSleepDurationNs(ns); } catch (ConfigurationException e) { if (e.getMessage().startsWith(\"Invalid idle sleep duration\")) { ctx.idleSleepDurationNs(clampIdleNs(ns)); } else throw e; }","preventionTips":["Clamp values read from external configuration","Watch unit mistakes: property files often specify ms, the API takes ns","Prefer ctx.idleStrategy(...) with a known strategy over raw ns tuning"],"tags":["configuration","idle-strategy","range-validation","duration"],"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-19T12:17:13.211Z"}