{"record":{"id":"57b3675c2b73efac","repo":"zhisheng17/flink-learning","slug":"the-value-text-cannot-be-re-represented-as-64","errorCode":null,"errorMessage":"The value '${text}' cannot be re represented as 64bit number of bytes (numeric overflow).","messagePattern":"The value '(.+?)' cannot be re represented as 64bit number of bytes \\(numeric overflow\\)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-learning-core/src/main/java/com/zhisheng/core/utils/TimeUtils.java","lineNumber":89,"sourceCode":"\t\t\tif (matchTimeUnit(unit, TimeUnit.MILLISECONDS)) {\n\t\t\t\tmultiplier = 1L;\n\t\t\t} else if (matchTimeUnit(unit, TimeUnit.SECONDS)) {\n\t\t\t\tmultiplier = 1000L;\n\t\t\t} else if (matchTimeUnit(unit, TimeUnit.MINUTES)) {\n\t\t\t\tmultiplier = 1000L * 60L;\n\t\t\t} else if (matchTimeUnit(unit, TimeUnit.HOURS)) {\n\t\t\t\tmultiplier = 1000L * 60L * 60L;\n\t\t\t} else {\n\t\t\t\tthrow new IllegalArgumentException(\"Time interval unit '\" + unit +\n\t\t\t\t\t\"' does not match any of the recognized units: \" + TimeUnit.getAllUnits());\n\t\t\t}\n\t\t}\n\n\t\tfinal long result = value * multiplier;\n\n\t\t// check for overflow\n\t\tif (result / multiplier != value) {\n\t\t\tthrow new IllegalArgumentException(\"The value '\" + text +\n\t\t\t\t\"' cannot be re represented as 64bit number of bytes (numeric overflow).\");\n\t\t}\n\n\t\treturn Duration.ofMillis(result);\n\t}\n\n\tprivate static boolean matchTimeUnit(String text, TimeUnit unit) {\n\t\treturn text.equals(unit.getUnit());\n\t}\n\n\t/**\n\t * Enum which defines time unit, mostly used to parse value from configuration file.\n\t */\n\tprivate enum TimeUnit {\n\t\tMILLISECONDS(\"ms\"),\n\t\tSECONDS(\"s\"),\n\t\tMINUTES(\"min\"),\n\t\tHOURS(\"h\");","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-core/src/main/java/com/zhisheng/core/utils/TimeUtils.java#L71-L107","documentation":"After computing value * multiplier in parseDuration, TimeUtils verifies the result by dividing back; if the round-trip does not reproduce the original value, the multiplication overflowed 64 bits. It throws this IllegalArgumentException instead of silently returning a wrapped-around duration.","triggerScenarios":"Parsing an enormous duration value like '9223372036854775807 h' or any value whose product with the unit multiplier exceeds Long.MAX_VALUE.","commonSituations":"Misconfigured values where a raw timestamp or byte count was pasted into a duration field; accidental repeated digits in config; programmatically computed durations not clamped before parsing.","solutions":["Reduce the numeric value in the duration string to a sane range (e.g. '2147483647 ms' max for typical use).","Use a larger unit to express the same duration (e.g. '2147483648 s' instead of milliseconds).","Pre-check the magnitude: if value > Long.MAX_VALUE / multiplierMillis, reject before calling parseDuration.","Catch IllegalArgumentException and surface a validation error to the user."],"exampleFix":"// before\nDuration d = TimeUtils.parseDuration(\"99999999999999999999 s\");\n// after\nlong seconds = 99999999999999999999L > Long.MAX_VALUE / 1000 ? Long.MAX_VALUE / 1000 : 99999999999999999999L;\nDuration d = Duration.ofSeconds(seconds);","handlingStrategy":"validation","validationCode":"static void checkDurationMagnitude(String text, long multiplierMillis) {\n    long value = Long.parseLong(text.trim().split(\"\\\\s+\")[0]);\n    if (value != 0 && value > Long.MAX_VALUE / multiplierMillis)\n        throw new IllegalArgumentException(\"Duration \" + text + \" overflows long milliseconds\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    d = TimeUtils.parseDuration(text);\n} catch (IllegalArgumentException e) {\n    d = Duration.ofMillis(Long.MAX_VALUE); // or fail fast with clear message\n}","preventionTips":["Clamp user-supplied duration values to a sane maximum before parsing","Never paste timestamps/byte counts into duration fields","Use larger units (h/d) for long durations instead of huge millisecond counts","Validate numeric ranges at config-load time, not at use time"],"tags":["overflow","duration","parsing"],"backgroundTag":"value-out-of-range","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}