prestodb/presto · error · IllegalArgumentException
Unparseable port number:
Error message
Unparseable port number:
What it means
When fromString finds a port suffix it parses it as a plain decimal integer. A leading '+' is rejected explicitly (JDK7 Integer.parseInt accepts it, but URI authority syntax does not), and any value Integer.parseInt cannot parse raises this error. The message quotes the full hostPortString for diagnosis.
Solutions
- Remove any leading '+' from the port substring
- Ensure the port suffix is pure ASCII digits 0-9
- Validate the "host:port" string with a regex like ^[^:]+:(\d+)$ before parsing
- Log the offending hostPortString to find the malformed source value
Example fix
// before
HostAddress.fromUri(new URI("http://host:+8080"));
// after
HostAddress.fromUri(new URI("http://host:8080")); Defensive patterns
Strategy: validation
Validate before calling
int idx = hostPort.lastIndexOf(':');
String portStr = hostPort.substring(idx + 1);
if (portStr.startsWith("+") || !portStr.matches("\\d+")) {
throw new IllegalArgumentException("Port suffix must be plain digits: " + hostPort);
} Try / catch
try {
addr = HostAddress.fromString(hostPort);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Bad host:port value in config: " + hostPort, e);
} Prevention
- Validate port suffix is pure ASCII digits before parsing
- Reject '+' prefixes explicitly
- Sanitize copy-pasted values (unicode digits, whitespace, units like '8080/tcp')
When it happens
Trigger: HostAddress.fromString("host:+8080") (leading plus) or fromString("host:80 80"), "host:8080x", "host:0x1F90", "host:8_080" — any port substring that is not pure decimal digits.
Common situations: Copy-pasted addresses with typographic or unicode digits; templated configs where the port variable was left empty or contained a placeholder; hand-built strings with stray characters.
Related errors
- host contains a port declaration:
- Invalid bracketed host/port:
- Port is invalid:
- Port number out of range:
- ARROW_FLIGHT_CLIENT_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/7a51cd66bb42a249.
Report an issue: GitHub.
Appendix: source
Thrown at presto-spi/src/main/java/com/facebook/presto/spi/HostAddress.java:206
else {
int colonPos = hostPortString.indexOf(':');
if (colonPos >= 0 && hostPortString.indexOf(':', colonPos + 1) == -1) {
// Exactly 1 colon. Split into host:port.
host = hostPortString.substring(0, colonPos);
portString = hostPortString.substring(colonPos + 1);
}
else {
// 0 or 2+ colons. Bare hostname or IPv6 literal.
host = hostPortString;
}
}
int port = NO_PORT;
if (portString != null && portString.length() != 0) {
// Try to parse the whole port string as a number.
// JDK7 accepts leading plus signs. We don't want to.
if (portString.startsWith("+")) {
throw new IllegalArgumentException("Unparseable port number: " + hostPortString);
}
try {
port = Integer.parseInt(portString);
}
catch (NumberFormatException e) {
throw new IllegalArgumentException("Unparseable port number: " + hostPortString);
}
if (!isValidPort(port)) {
throw new IllegalArgumentException("Port number out of range: " + hostPortString);
}
}
return new HostAddress(host, port);
}
public static HostAddress fromUri(URI httpUri)
{
String host = httpUri.getHost();View on GitHub (pinned to 55bb57d202)