{"record":{"id":"4bfd5eb1b40b525f","repo":"zhisheng17/flink-learning","slug":"the-value-number-cannot-be-re-represented-as","errorCode":null,"errorMessage":"The value '${number}' cannot be re represented as 64bit number (numeric overflow).","messagePattern":"The value '(.+?)' cannot be re represented as 64bit number \\(numeric overflow\\)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-learning-core/src/main/java/com/zhisheng/core/utils/TimeUtils.java","lineNumber":63,"sourceCode":"\t\tint pos = 0;\n\n\t\tchar current;\n\t\twhile (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {\n\t\t\tpos++;\n\t\t}\n\n\t\tfinal String number = trimmed.substring(0, pos);\n\t\tfinal String unit = trimmed.substring(pos).trim().toLowerCase(Locale.US);\n\n\t\tif (number.isEmpty()) {\n\t\t\tthrow new NumberFormatException(\"text does not start with a number\");\n\t\t}\n\n\t\tfinal long value;\n\t\ttry {\n\t\t\tvalue = Long.parseLong(number); // this throws a NumberFormatException on overflow\n\t\t} catch (NumberFormatException e) {\n\t\t\tthrow new IllegalArgumentException(\"The value '\" + number +\n\t\t\t\t\"' cannot be re represented as 64bit number (numeric overflow).\");\n\t\t}\n\n\t\tfinal long multiplier;\n\t\tif (unit.isEmpty()) {\n\t\t\tmultiplier = 1L;\n\t\t} else {\n\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());","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-core/src/main/java/com/zhisheng/core/utils/TimeUtils.java#L45-L81","documentation":"TimeUtils.parseDuration parses the numeric part with Long.parseLong; if the number overflows a 64-bit long (or is otherwise unparseable as a long), it rethrows as IllegalArgumentException stating the value cannot be represented as a 64-bit number.","triggerScenarios":"Passing a duration string whose numeric part exceeds Long.MAX_VALUE (9223372036854775807), e.g. '99999999999999999999 ms', or a non-integer numeric literal like '1.5 h'.","commonSituations":"Hand-written configs with absurdly large durations, durations written in small units that overflow when someone adds a multiplier, or decimal durations copied from other tooling.","solutions":["Reduce the numeric value so it fits in a signed 64-bit long (or convert to a larger unit, e.g. use '1 d' instead of milliseconds)","Use an integer literal without decimals","Validate magnitude (<= 9223372036854775807) before parsing"],"exampleFix":"// before\nTimeUtils.parseDuration(\"99999999999999999999 ms\");\n// after\nTimeUtils.parseDuration(\"99999999999999999999 s\"); // or a value within Long.MAX_VALUE","handlingStrategy":"validation","validationCode":"static boolean fitsInLong(String number) {\n    try { Long.parseLong(number.trim()); return true; }\n    catch (NumberFormatException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    long ms = TimeUtils.parseDuration(text);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"64bit\")) {\n        LOG.warn(\"Duration '{}' overflows a 64-bit long\", text);\n        ms = Long.MAX_VALUE; // or clamp/default\n    } else throw e;\n}","preventionTips":["Keep duration numbers well below Long.MAX_VALUE (9223372036854775807)","Express long durations in bigger units ('30 d' instead of milliseconds)","Reject non-integer numbers (e.g. '1.5 h') in config validation before parsing"],"tags":["java","parsing","duration","overflow"],"backgroundTag":"invalid-duration-format","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}