zhisheng17/flink-learning · error · IllegalArgumentException
The value '${number}' cannot be re represented as 64bit numb
Error message
The value '${number}' cannot be re represented as 64bit number (numeric overflow). What it means
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.
Source
Thrown at flink-learning-core/src/main/java/com/zhisheng/core/utils/TimeUtils.java:63
int pos = 0;
char current;
while (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {
pos++;
}
final String number = trimmed.substring(0, pos);
final String unit = trimmed.substring(pos).trim().toLowerCase(Locale.US);
if (number.isEmpty()) {
throw new NumberFormatException("text does not start with a number");
}
final long value;
try {
value = Long.parseLong(number); // this throws a NumberFormatException on overflow
} catch (NumberFormatException e) {
throw new IllegalArgumentException("The value '" + number +
"' cannot be re represented as 64bit number (numeric overflow).");
}
final long multiplier;
if (unit.isEmpty()) {
multiplier = 1L;
} else {
if (matchTimeUnit(unit, TimeUnit.MILLISECONDS)) {
multiplier = 1L;
} else if (matchTimeUnit(unit, TimeUnit.SECONDS)) {
multiplier = 1000L;
} else if (matchTimeUnit(unit, TimeUnit.MINUTES)) {
multiplier = 1000L * 60L;
} else if (matchTimeUnit(unit, TimeUnit.HOURS)) {
multiplier = 1000L * 60L * 60L;
} else {
throw new IllegalArgumentException("Time interval unit '" + unit +
"' does not match any of the recognized units: " + TimeUnit.getAllUnits());View on GitHub (pinned to d731cee761)
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
Example fix
// before
TimeUtils.parseDuration("99999999999999999999 ms");
// after
TimeUtils.parseDuration("99999999999999999999 s"); // or a value within Long.MAX_VALUE Defensive patterns
Strategy: validation
Validate before calling
static boolean fitsInLong(String number) {
try { Long.parseLong(number.trim()); return true; }
catch (NumberFormatException e) { return false; }
} Try / catch
try {
long ms = TimeUtils.parseDuration(text);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("64bit")) {
LOG.warn("Duration '{}' overflows a 64-bit long", text);
ms = Long.MAX_VALUE; // or clamp/default
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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'.
Common situations: 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.
Understand the failure class
Background: "invalid duration" / "failed to parse duration": why your timeout, interval, or TTL string is rejected and which formats each library accepts — this error's family across 32 libraries.
Related errors
- text does not start with a number
- The value '${text}' cannot be re represented as 64bit number
- Time interval unit '${unit}' does not match any of the recog
- bytes == null
- The given argument is no array.
AI-assisted analysis of zhisheng17/flink-learning@d731cee761 (2026-09-06).
Data as JSON: /api/errors/4bfd5eb1b40b525f.
Report an issue: GitHub.