{"record":{"id":"06c854ff29116cea","repo":"aeron-io/aeron","slug":"unsupported-time-unit-timeunit","errorCode":null,"errorMessage":"unsupported time unit: <timeUnit>","messagePattern":"unsupported time unit: <timeUnit>","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-cluster/src/main/java/io/aeron/cluster/service/ClusterClock.java","lineNumber":109,"sourceCode":"     *\n     * @param timeUnit to map to a corresponding {@link ClusterTimeUnit}.\n     * @return a corresponding {@link ClusterTimeUnit}.\n     */\n    static ClusterTimeUnit map(final TimeUnit timeUnit)\n    {\n        switch (timeUnit)\n        {\n            case MILLISECONDS:\n                return ClusterTimeUnit.MILLIS;\n\n            case MICROSECONDS:\n                return ClusterTimeUnit.MICROS;\n\n            case NANOSECONDS:\n                return ClusterTimeUnit.NANOS;\n\n            default:\n                throw new IllegalArgumentException(\"unsupported time unit: \" + timeUnit);\n        }\n    }\n\n    /**\n     * Map {@link ClusterTimeUnit} to a corresponding {@link TimeUnit}.\n     *\n     * @param clusterTimeUnit to map to a corresponding {@link TimeUnit}.\n     * @return a corresponding {@link TimeUnit}, if {@link ClusterTimeUnit#NULL_VAL} is passed then defaults\n     * to {@link TimeUnit#MILLISECONDS}.\n     */\n    static TimeUnit map(final ClusterTimeUnit clusterTimeUnit)\n    {\n        switch (clusterTimeUnit)\n        {\n            case NULL_VAL:\n            case MILLIS:\n                return TimeUnit.MILLISECONDS;\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-cluster/src/main/java/io/aeron/cluster/service/ClusterClock.java#L91-L127","documentation":"ClusterClock.map converts a java.util.concurrent.TimeUnit to its ClusterTimeUnit representation (used in cluster mark file headers); TimeUnit values with no ClusterTimeUnit equivalent (e.g. MILLISECONDS, SECONDS, DAYS) hit the default branch and IllegalArgumentException is thrown.","triggerScenarios":"Passing TimeUnit.MILLISECONDS (or SECONDS/DAYS/MICRO-second-units not in the supported set) into ClusterClock.map when configuring or inspecting cluster time units.","commonSituations":"Custom cluster clock configuration using an unsupported TimeUnit; generic time-unit plumbing that passes arbitrary units into Aeron cluster APIs.","solutions":["Use only TimeUnit.NANOSECONDS or TimeUnit.MICROSECONDS with ClusterClock.map","Normalize other units to nanoseconds before mapping (e.g. timeUnit.toNanos())","Guard with a check on the TimeUnit before calling map"],"exampleFix":"// before\nClusterTimeUnit ctu = ClusterClock.map(TimeUnit.MILLISECONDS);\n// after\nClusterTimeUnit ctu = ClusterClock.map(\n    timeUnit == TimeUnit.MICROSECONDS ? TimeUnit.MICROSECONDS : TimeUnit.NANOSECONDS);","handlingStrategy":"validation","validationCode":"if (timeUnit != TimeUnit.NANOSECONDS && timeUnit != TimeUnit.MICROSECONDS) {\n    throw new IllegalArgumentException(\"ClusterClock supports only NANOS/MICROS\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ClusterTimeUnit ctu = ClusterClock.map(timeUnit);\n} catch (IllegalArgumentException ex) {\n    // normalize to NANOSECONDS and retry\n}","preventionTips":["Restrict cluster time config to NANOSECONDS/MICROSECONDS","Convert other units with toNanos() before mapping","Document accepted TimeUnits in configuration code"],"tags":["aeron","time-unit","enum"],"backgroundTag":"unsupported-enum-value","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"}