chinabugotech/hutool · error · UtilException
OVERFLOW
Error message
OVERFLOW
What it means
Thrown by PunyCode.encode() when the delta value would overflow Integer.MAX_VALUE during the Punycode encoding loop. Specifically when (m - n) exceeds the safe remaining capacity divided by (h + 1). This is a guard against arithmetic overflow per the RFC 3492 specification. It indicates the input is pathologically large or contains code points that cause extreme delta accumulation.
Source
Thrown at hutool-core/src/main/java/cn/hutool/core/codec/PunyCode.java:105
if (b > 0) {
if(b == length){
// 无需要编码的字符
return output.toString();
}
output.append(DELIMITER);
}
int h = b;
while (h < length) {
int m = Integer.MAX_VALUE;
// Find the minimum code point >= n
for (int i = 0; i < length; i++) {
final char c = input.charAt(i);
if (c >= n && c < m) {
m = c;
}
}
if (m - n > (Integer.MAX_VALUE - delta) / (h + 1)) {
throw new UtilException("OVERFLOW");
}
delta = delta + (m - n) * (h + 1);
n = m;
for (int j = 0; j < length; j++) {
int c = input.charAt(j);
if (c < n) {
delta++;
if (0 == delta) {
throw new UtilException("OVERFLOW");
}
}
if (c == n) {
int q = delta;
for (int k = BASE; ; k += BASE) {
int t;
if (k <= bias) {
t = TMIN;
} else if (k >= bias + TMAX) {View on GitHub (pinned to 8870454b2a)
Solutions
- Catch UtilException around the encode call and report the input as too large to encode.
- Validate input length before encoding — reject strings longer than a reasonable domain label limit (253 chars for FQDN, 63 per label).
- Split very long inputs into smaller segments before encoding.
Example fix
// before
String punycode = PunyCode.encode(veryLongUnicodeString); // may throw OVERFLOW
// after
try {
String punycode = PunyCode.encode(veryLongUnicodeString);
} catch (UtilException e) {
if ("OVERFLOW".equals(e.getMessage())) {
// input too large, reject or split
throw new IllegalArgumentException("Input too large for Punycode encoding", e);
}
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Limit input length to prevent overflow
if (input.length() > 1000) {
throw new IllegalArgumentException("Input too long for Punycode encoding");
} Try / catch
try {
String encoded = PunyCode.encode(input);
} catch (UtilException e) {
if ("OVERFLOW".equals(e.getMessage())) {
throw new IllegalArgumentException("Input too large", e);
}
throw e;
} Prevention
- Limit input length before encoding.
- Use encodeDomain() for domain processing to split into smaller labels.
- Prefer java.net.IDN for production domain handling.
When it happens
Trigger: Encoding a CharSequence with a very large number of non-ASCII characters or extremely high Unicode code points that cause the delta arithmetic to exceed Integer.MAX_VALUE. This is theoretically possible with adversarial input or very long Unicode strings.
Common situations: Processing extremely long internationalized domain name (IDN) labels. Adversarial input designed to trigger integer overflow. In practice, normal domain names and Unicode strings will never hit this limit because the input length bounds are well within safe range for int arithmetic.
Related errors
- BAD_INPUT
- Illegal hexadecimal character {} at index {}
- Base58 checksum is invalid
- Invalid char '{}' at [{}]
- invalid number: {number}
AI-assisted analysis of chinabugotech/hutool@8870454b2a (2026-08-14).
Data as JSON: /api/errors/7d0ad8c3985d509b.
Report an issue: GitHub.